C# 如何在Azure中执行区分大小写的LINQ查询?
我正在使用Windows Azure存储表,希望查询对象。用户输入一个字符串,我在数据库中查找该字符串,如下所示:C# 如何在Azure中执行区分大小写的LINQ查询?,c#,linq,azure,azure-table-storage,C#,Linq,Azure,Azure Table Storage,我正在使用Windows Azure存储表,希望查询对象。用户输入一个字符串,我在数据库中查找该字符串,如下所示: var myKey = "SomeCaseSensitiveKeyInputByTheUser"; var someObject = (from o in dataContext.Objects where o.SomeString.Equals(myKey) select o).FirstOrDefault(); 但是,由于某些原因,所有字符串比较似乎都不区分
var myKey = "SomeCaseSensitiveKeyInputByTheUser";
var someObject = (from o in dataContext.Objects
where o.SomeString.Equals(myKey)
select o).FirstOrDefault();
但是,由于某些原因,所有字符串比较似乎都不区分大小写(包括=
和string.Equals()
)。但是,我需要匹配用户输入字符串的确切大小写
如何在LINQ查询中执行此操作?使用
==
与.Equals(..)
相同,因为它只调用该方法。
您可以使用传递字符串的Equal()重载强制使用区分大小写的比较。comparison
enum
CurrentCulture Compare strings using culture-sensitive sort rules and the current culture.
CurrentCultureIgnoreCase Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared.
InvariantCulture Compare strings using culture-sensitive sort rules and the invariant culture.
InvariantCultureIgnoreCase Compare strings using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings being compared.
Ordinal Compare strings using ordinal sort rules.
OrdinalIgnoreCase Compare strings using ordinal sort rules and ignoring the case of the strings being compared.
更多信息,请访问:
使用
==
与.Equals(..)
相同,因为它只是调用该方法。
您可以使用传递字符串的Equal()重载强制使用区分大小写的比较。comparison
enum
CurrentCulture Compare strings using culture-sensitive sort rules and the current culture.
CurrentCultureIgnoreCase Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared.
InvariantCulture Compare strings using culture-sensitive sort rules and the invariant culture.
InvariantCultureIgnoreCase Compare strings using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings being compared.
Ordinal Compare strings using ordinal sort rules.
OrdinalIgnoreCase Compare strings using ordinal sort rules and ignoring the case of the strings being compared.
更多信息,请访问:
您是否尝试使用equals的StringComparison重载?就像i.SomeString.Equals(mykey,StringComparer.CurrentCulture)一样,您是否尝试使用Equals的StringComparation重载?就像i.SomeString.Equals(mykey、StringComparer.CurrentCulture)一样,我尝试过重载,但结果证明我在其他地方犯了一个相当愚蠢的错误。然而,CurrentCulture最终做到了这一点。谢谢。我试过过载,但结果我在别处犯了一个相当愚蠢的错误。然而,CurrentCulture最终做到了这一点。谢谢