C# 如何使用N'';对于非Unicode字符,是否在Linq to实体中?
如何在Linq to实体中使用N“”,例如在T-SQL中,我们有以下代码:C# 如何使用N'';对于非Unicode字符,是否在Linq to实体中?,c#,tsql,linq-to-entities,C#,Tsql,Linq To Entities,如何在Linq to实体中使用N“”,例如在T-SQL中,我们有以下代码: select *from students where name=N'سیروان عفیفی' var query = from p in dbContext.Students where p.Name == "سیروان عفیفی" select p; 我有以下代码: select *from st
select *from students where name=N'سیروان عفیفی'
var query = from p in dbContext.Students
where p.Name == "سیروان عفیفی"
select p;
我有以下代码:
select *from students where name=N'سیروان عفیفی'
var query = from p in dbContext.Students
where p.Name == "سیروان عفیفی"
select p;
如何使用Linq to Entity执行此操作
我发现:
但它不起作用
谢谢 如果列类型以“n”开头,如
nvarchar
或nchar
,则无需在第一个值处添加n”
我尝试了以下方法,并与nvarchar
x.Name == "سیروان عفیفی"
您是否检查了生成的查询?是否也可以发布它?是否可以尝试使用
EntityFunctions.AsUnicode
替代?@w0lf它用于unicode字符。如果模型中的Name属性标记为unicode,您应该在查询中获得N“”。另外请注意,在C中,字符是unicode设计的:char关键字用于声明System.char结构的实例,该结构表示Unicode字符“@Pawel如何获取查询中的N”?