linq case insensitive (without toUpper or toLower)
Use String.Equals
with the appropriate parameters to make it case insensitive
mySource.Where(s => String.Equals(s, "Foo", StringComparison.CurrentCultureIgnoreCase));
Instead of ==
use the .Equals(name, StringComparison.OrdinalIgnoreCase)
method.
var query = from article in session.Linq<Articles>()
where article.Name.Equals(name, StringComparison.OrdinalIgnoreCase) &&
article.Category.Equals(category) &&
article.Company.Equals(company)
select article;
return query.FirstOrDefault();
If this is a LINQ to SQL query against a database with a case-insensitive collation, then it already is case-insensitive. Remember that LINQ to SQL isn't actually executing your == call; it's looking at it as an expression and converting it to an equality operator in SQL.
If it's LINQ to Objects, then you can use String.Equals as the other posters have pointed out.