当前位置: 动力学知识库 > 问答 > 编程问答 >

sql server - Case sensitive varchar match with LINQ

问题描述:

What LINQ query can I write to perform a case sensitive match on two varchar columns when I do not have the option of changing or adding to the database schema?

I've considered using COLLATE, but understand that this is not possible with LINQ. Is this correct?

Alternatively, I could use the CONVERT function to match VARBINARY values, but don't know how that can be implemented with LINQ.

Before marking this as a duplicate, consider that I'm looking for a LINQ query and not any solution that involves changing or adding to the database schema.

网友答案:

You could try:

table.Where(_ => _.col1 == "seArch").AsEnumerable().Where(_ => _.col1 == "seArch");

First Where will use SQL server's COLLATE which will return case insensitive results, 2nd where will use case sensitive search.

分享给朋友:
您可能感兴趣的文章:
随机阅读: