I am using Windows Azure Storage Tables, and want to query for an object. The user inputs a string, which I look for in the database as such:
var myKey = "SomeCaseSensitiveKeyInputByTheUser";
var someObject = (from o in dataContext.Objects
where o.SomeString.Equals(myKey)
select o).FirstOrDefault();
However, for some reason, all string comparisons appear to be case insensitive (both == and string.Equals()). However, I need to match the exact casing of the user input string.
How can I do this in my LINQ query?
Using
==is the same as.Equals(..), as it just calls that method.You can force to use a case sensitive comparison using an overload of Equal() passing a
string.comparisonenummore info at:
http://msdn.microsoft.com/en-us/library/system.stringcomparison.aspx