Closed jetro44 closed 5 years ago
Contains method searching only in string.
@mrxten is there any way, how to search in numeric type with usage of QueryDesigner?
No ofc. How you imagine it in Expression and finally in SQL?
On 4 Mar 2019, at 11:09, jetro44 notifications@github.com wrote:
@mrxten is there any way, how to search in numeric type with usage of QueryDesigner?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@mrxten
I'm looking for something like this:
SELECT Id,ColumnAsInt
FROM SomeTable
WHERE ColumnAsInt like CAST(527 as nvarchar) + '%'
527 is search value
RESULT:
Id ColumnAsInt
3742 52700
3416 52701
2578 52704
2448 52705
Hmm, could you show how would you implement this request via Entity Framework?
@mrxten
I see, why you ask this question... CAST seems to be not supported in EF, but it is possible to call something like this:
query.where(o => EF.Functions.Like(o.ColumnAsInt.ToString(), "%" + searchValue + "%"))
I apologize for my insufficient knowledge. However, this is one of the reasons I would like to implement searching via your QueryDesigner. If you have any idea, how to search in int columns (and other numerous types), I will appreciate it.
Nevertheless, thanks for QD, its helpful.
Entity framework doesn't support extended method ToString. I'm afraid this cannot be implement via .net expression. Or I just didn't find way.
Thanks @mrxten. I'll try to make some overriding on business layer of our solution (but in combination of your QD). We should wait for EF improvement...
When I use filter for searching objects by property of type int (or non-string but numeric) with WhereFilterType.Contains exp is thrown.
I tried this:
but I got error:
The binary operator OrElse is not defined for the types 'System.Boolean' and 'System.Int32'. System.Linq.Expressions.Expression.OrElse(Expression left, Expression right, MethodInfo method) System.Linq.Expressions.Expression.OrElse(Expression left, Expression right)
Any idea how to search by numeric property?