English 中文(简体)
如何在Azure 执行对案件敏感的 LINQ 查询?
原标题:How to perform a case-sensitive LINQ query in Azure?

我正在使用 Windows Azure 存储表, 想要查询对象。 用户输入字符串, 我在数据库中查找 :

var myKey = "SomeCaseSensitiveKeyInputByTheUser";

var someObject = (from o in dataContext.Objects
    where o.SomeString.Equals(myKey)
    select o).FirstOrDefault();

然而,出于某种原因,所有字符串比较似乎都对案例不敏感(包括 stringing.Equals () )。然而,我需要匹配用户输入字符串的确切外壳。

在LINQ的查询中我怎么能做这个呢?

最佳回答

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.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.

更多信息 :

http://msdn.microsoft.com/en-us/library/system.stringcomparisson.aspx" rel=“nofollow'>http://msdn.microsoft.com/en-us/library/system.stringcomparison.aspx

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...