juF*_*uFo 8 c# entity-framework-core ef-core-3.0
在 EF Core 3.0 之前,这工作正常(在服务器+客户端上评估):
var exists = await _context.Countries.AsNoTracking().AnyAsync(x => x.CountryCode.Equals(country.CountryCode, StringComparison.OrdinalIgnoreCase));
Run Code Online (Sandbox Code Playgroud)
string.Equals(str, StringComparison.OrdinalIgnoreCase)现在在 EF Core 3.0 中翻译-part的最佳/首选方法是什么,以便查询仅在服务器端评估。
var exists = await _context.Countries.AsNoTracking().AnyAsync(x => x.CountryCode.ToUpper() == country.CountryCode.ToUpper());
Run Code Online (Sandbox Code Playgroud)
或者
var exists = await _context.Countries.AsNoTracking().AnyAsync(x => x.CountryCode.ToLower() == country.CountryCode.ToLower());
Run Code Online (Sandbox Code Playgroud)
或者
var exists = await _context.Countries.AsNoTracking().AnyAsync(x => x.CountryCode.ToUpperInvariant() == country.CountryCode.ToUpperInvariant());
Run Code Online (Sandbox Code Playgroud)
或者
var exists = await _context.Countries.AsNoTracking().AnyAsync(x => x.CountryCode.ToLowerInvariant() == country.CountryCode.ToLowerInvariant());
Run Code Online (Sandbox Code Playgroud)
或者是其他东西?
L.T*_*hin 11
您不应该这样做,也不应该使用公认的答案方法,您应该只使用不带参数的 String.Equals() 并在创建或迁移期间配置您的数据库排序规则。
| 归档时间: |
|
| 查看次数: |
5699 次 |
| 最近记录: |