I have a scenario that I have string value in c# and in SQL server the data type is decimal and requirement is that i have to filter value like we do in string which includes (startswith,endswith,contains etc) filters. I am trying like this :
customers = customers.Where(x => Convert.ToString(x.CrmCustomerNumber).Contains(value));
but it's give me error because you can't use Convert.tostring in IQuerable. I know that I can do that
customers.ToList().Where(x => Convert.ToString(x.CrmCustomerNumber).Contains(value));
but I am doing Customer.ToList() at the end after applying all filters. is there any solution of my problem?
System.Decimaland specifying the correct scale and precision in your SQL Command parameters takes care of thatstartswith. This would still force a full table scan, when a range query would use the primary key. Besides, this would require an integer or bigint, not a decimal. Whatever the real requirement is, it can be handled without resorting to full-table scansLIKE '%123%to do it? There's probably another way to do thismany-to-manyrelation. In this case, redesigning the schema would fix the problem and improve performance