When I try to use ToString() inside the below LINQ Lambda expression, I get an exception saying "LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression."
query = query.Where(q => q.date.ToString().Contains(filtertext)
|| q.invoicenum.ToString().Contains(filtertext)
|| q.trans_type.ToString().Contains(filtertext)
|| q.charge.Contains(filtertext));
I am using Linq to entites. And the Database used is MySQL and not the SQL Server. Immediate help would be highly appreciated.
I resolved this issue by directly writing MySQl query inside C# as below -
string queryTemplate =
@"select inv.* from invoices as inv where userID = '123' and date like '%abc%'";
List<invoice> totalSearch =
context.ExecuteStoreQuery<invoice>(queryTemplate).ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With