You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if Poco class has a nullable member, e.g.
public class SomePocoClass
{
int? Number get;set;}
}
and the following query is run against it
var somelist = new List { 1,2,3,4};
var items = database.Query().Where(x => somlist.Contains(x.Number.Value)).ToList();
the .Value property of Nullable is treated as if Number were a nested class in SomePocoClass. This causes the following exception:
Did you forget to include the property eg. Include(x => x.Number)
Stack:
at NPoco.Expressions.SqlExpression1.VisitMemberAccess(MemberExpression m) at NPoco.Expressions.SqlExpression1.Visit(Expression exp)
at NPoco.Expressions.SqlExpression1.VisitExpressionList(ReadOnlyCollection1 original)
at NPoco.Expressions.SqlExpression1.VisitStaticArrayMethodCall(MethodCallExpression m) at NPoco.Expressions.SqlExpression1.VisitMethodCall(MethodCallExpression m)
at NPoco.Expressions.SqlExpression1.Visit(Expression exp) at NPoco.Expressions.SqlExpression1.VisitLambda(LambdaExpression lambda)
at NPoco.Expressions.SqlExpression1.Visit(Expression exp) at NPoco.Expressions.SqlExpression1.ProcessInternalExpression()
at NPoco.Expressions.SqlExpression1.And(Expression1 predicate)
at NPoco.Expressions.SqlExpression1.Where(Expression1 predicate)
at NPoco.Linq.QueryProvider1.Where(Expression1 whereExpression)
I.e. NPoco does not transate .Contains into SQL where Number in (...), because it stumbles at the .Value property of the nullable parameter of .Contains
If somelist is declared as List<int?> everything works just fine.
The text was updated successfully, but these errors were encountered:
if Poco class has a nullable member, e.g.
public class SomePocoClass
{
int? Number get;set;}
}
and the following query is run against it
var somelist = new List { 1,2,3,4};
var items = database.Query().Where(x => somlist.Contains(x.Number.Value)).ToList();
the .Value property of Nullable is treated as if Number were a nested class in SomePocoClass. This causes the following exception:
Did you forget to include the property eg. Include(x => x.Number)
Stack:
at NPoco.Expressions.SqlExpression
1.VisitMemberAccess(MemberExpression m) at NPoco.Expressions.SqlExpression
1.Visit(Expression exp)at NPoco.Expressions.SqlExpression
1.VisitExpressionList(ReadOnlyCollection
1 original)at NPoco.Expressions.SqlExpression
1.VisitStaticArrayMethodCall(MethodCallExpression m) at NPoco.Expressions.SqlExpression
1.VisitMethodCall(MethodCallExpression m)at NPoco.Expressions.SqlExpression
1.Visit(Expression exp) at NPoco.Expressions.SqlExpression
1.VisitLambda(LambdaExpression lambda)at NPoco.Expressions.SqlExpression
1.Visit(Expression exp) at NPoco.Expressions.SqlExpression
1.ProcessInternalExpression()at NPoco.Expressions.SqlExpression
1.And(Expression
1 predicate)at NPoco.Expressions.SqlExpression
1.Where(Expression
1 predicate)at NPoco.Linq.QueryProvider
1.Where(Expression
1 whereExpression)I.e. NPoco does not transate .Contains into SQL where Number in (...), because it stumbles at the .Value property of the nullable parameter of .Contains
If somelist is declared as List<int?> everything works just fine.
The text was updated successfully, but these errors were encountered: