2012-10-15 8 views
6

Come posso usare N '' in LINQ to entità, ad esempio in T-SQL che abbiamo avuto questo codice:Come posso utilizzare N '' in Linq su Entità per caratteri non Unicode?

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

ho questo codice:

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

come posso fare questo con LINQ all'entità?

ho trovato this:

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

Ma non funziona.

Grazie.

+1

Hai controllato la query generato? Puoi postare anche tu? –

+0

puoi provare invece 'EntityFunctions.AsUnicode'? – GolfWolf

+0

@ w0lf è per carattere unicode. –

risposta

0

Se il tipo di colonna è stato avviato con 'n' come nvarchar o nchar, non è necessario aggiungere N" al primo valore.

ho provato quanto segue e ha funzionato con nvarchar

x.Name == "سیروان عفیفی" 
Problemi correlati