I'm trying to create a not in
clause with the NHibernate Criteria API using NHLambdaExtensions. Reading the documentation I was able to implement the in
clause by doing
.Add(SqlExpression.In<Zone>(z => zoneAlias.ZoneId, new int[] { 1008, 1010 }))
However, when I wrap it around SqlExpression.Not
I get the error
Error 5 The best overloaded method match for 'NHibernate.LambdaExtensions.SqlExpression.Not<oms_dal.Models.Zone>(System.Linq.Expressions.Expression<System.Func<oms_dal.Models.Zone,bool>>)' has some invalid arguments
Error 6 Argument '1': cannot convert from 'NHibernate.Criterion.ICriterion' to 'System.Linq.Expressions.Expression<System.Func<oms_dal.Models.Zone,bool>>'
I'm using this piece of code
.Add(SqlExpression.Not<Zone>(SqlExpression.In<Zone>(x => zoneAlias.ZoneId, new int[] { 1008, 1010 })))
How can I accomplish this? Using the regular Criteria API I was able to do this
.Add(Restrictions.Not(Restrictions.In("z.ZoneId", new[] { 1008, 1010 })))