Reputation: 500
I'm using dynamic linq to build a query in runtime. I'm preparing the following command
var temp = list
.AsQueryable()
.Where("Date<DateTime(2014,10,22,21,05,56)")
.Select("it");
return temp.Cast<T>().ToList();
The condition is not executing properly and i'm getting a wrong set of results. My filter condition is dynamic and i'll generate it only in run time. Can you help me in resolving this issue. Is there a Hour minute second comparison possible in dynamic linq?
Upvotes: 0
Views: 1873
Reputation: 109117
When I use the NuGet package I can execute your predicate alright. But I would use a parameter anyway:
var temp = list
.AsQueryable()
.Where("Date < @0", new DateTime(2014,10,22,21,05,56))
.Select("it");
return temp.Cast<T>().ToList();
Upvotes: 1
Reputation: 930
Please refer this link
As per the information from that link
Note that constructor invocations are not prefixed by new. The following example creates a DateTime instance for a specfic year, month, and day using a constructor invocation:
orders.Where("OrderDate >= DateTime(2007, 1, 1)");
Only difference I can see there is it is taking only 3 arguments. The author may not have implemented the overloaded version. Try with three parameters, instead.
Upvotes: 2