I have an IQueryable<SomeObject> query which contains a property Value which is a double.
I want to filter it by a string that has dot thousands separator comma before decimal (european).
I've tried the following: query.Where(q => q.Value.ToString("#,##0.00").StartsWith(someValue)
The issue is that it couldnt be translated: Translation of method 'double.ToString' failed. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'.
For my case it is not possible to convert to client evaluation as still need to apply form several other filters to my query. Is there any way to resolve this?
I think
ToString()doesnt accept your string format.It is not the best idea to stringify double, especially when it is a number which is perfect type to use logic with.
Change your:
to
then, you want to take values that "starts with" so with values (for
2.11) it can be: