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
{{ message }}
Repository navigation
Issue with Where Clause for a DataTable - String Works - Integer does not... ? #959
I have a bunch of DataTables I need to query dynamically.
I have a GenerateClause function that generates a simple where clause based on the type of column being queried...
For example, a String column might look like (City = "Seattle")
and an Int32 field might look like (Size = 3)
However, the string field where clause works fine - but the Int32 field does not work - and generates an error "Specified Cast is not Valid"
Any thoughts as to what might be causing this error message? I will need to put DataTime, Doubles, DateOnly, etc. where clauses as well as the String and Int32.
Here is the code I am using - where the GenateWhereClause is used to gen the string containing the actual clause...
It appears that using DynamicLINQ with Int64, Double, and some other field types all hinges on how you have the Where clause formatted
I was using a where clause that was generated and it looked like Int64Col == 11 for example - and it failed when I then ran the following command dynamicQuery.Where(DynLinqConfig, CurrWhereClause).ToList();
It all works fine. It is functionally the same - but DynamicLINQ seems to have an issue telling how to map the datatype if you don't use parameters.
This will make it a little difficult to use my current GenerateWhereClause code - but I can figure a way around that.
Thought I would post this here to help anyone else that runs into this issue.
Activity
CDNConsultant commentedon Nov 21, 2025
It appears that using DynamicLINQ with Int64, Double, and some other field types all hinges on how you have the Where clause formatted
I was using a where clause that was generated and it looked like Int64Col == 11 for example - and it failed when I then ran the following command
dynamicQuery.Where(DynLinqConfig, CurrWhereClause).ToList();HOWEVER, if you use parameters such as ...
It all works fine. It is functionally the same - but DynamicLINQ seems to have an issue telling how to map the datatype if you don't use parameters.
This will make it a little difficult to use my current GenerateWhereClause code - but I can figure a way around that.
Thought I would post this here to help anyone else that runs into this issue.