Dynamically create a Expression, Define the parameter of the Expression as below
var parameter = Expression.Parameter(typeof(T));
then pass this expression to MongoQueryable.Where function
call Count or ToList
reported the below exception
Value cannot be null.
Parameter name: itemName
on the other hand, if i declare the parameter of the expression as below
var parameter = Expression.Parameter(typeof(T),"item");
then the linq expression can be successfully transformed to mongodb query
while transform the linq expression to mongodb query, why does the parameter name is required? when it comes to dynamically generated expression people usually use anonymous parameter and the exception message does not explicitly indicate the parameter expression need a name.
- depends on
-
CSHARP-3648 LINQ3: Handle null ParameterExpression.Name
- Closed
- is duplicated by
-
CSHARP-3603 ArgumentNullException when passing Expression to mongodb IQueryable
- Closed