How can I use N '' in Linq for Entity for Unicode characters?

How can I use N '' in Linq for Entity, for example, in T-SQL we had this code:

select *from students where name=N'سیروان عفیفی' 

I have this code:

 var query = from p in dbContext.Students where p.Name == "سیروان عفیفی" select p; 

How can I do this with Linq to Entity?

I found this :

  var query = (from p in dbContext.Students where p.Name == EntityFunctions.AsNonUnicode("سیروان عفیفی") select p); 

But it does not work.

Thanks.

+6
source share
1 answer

If the column type is started using "n", like nvarchar or nchar , you do not need to add N" to the first part of your value.

I tried the following and worked with nvarchar

 x.Name == "سیروان عفیفی" 
0
source

Source: https://habr.com/ru/post/927722/


All Articles