透過SQL語法或在C# 使用EF的情況下,查詢DB的資料區分大小寫
SQL
select * from Goods
where code
COLLATE SQL_Latin1_General_CP1_CS_AS = N'C2fF7Fe' /*有大小寫*/
C# EF
var goods = context.Goods
.Where(c => EF.Functions.Collate(g.code, "SQL_Latin1_General_CP1_CS_AS") == "C2fF7Fe") //有大小寫
.ToList();
資料來源: https://docs.microsoft.com/zh-tw/ef/core/miscellaneous/collations-and-case-sensitivity