Case insensitive string compare with linq-to-sql and linq-to-objects

.net, linq, linq-to-objects, linq-to-sql

Solution

I'm not an expert in linq to sql, but you could just use the ToUpperInvariant() method of string before compareing.

Problem

see also Differences between LINQ to Objects and LINQ to SQL queries We are using the some queries over our database and our in memory objects. What is the best way of doing an insensitive string compare with linq-to-sql so that? - It runs fast on SQL Server - The same query expression can be used with linq-to-objects to get the same result Using ``` a.ToLowerInvariant() == b.ToLowerInvariant() ``` at least gets the same results, but it does not get processed on SQL server as far as I can tell, so can be a lot slower then ``` a == b ```

Original source

Related problems