Linq,如何搜索法语口音

时间:2013-08-15 19:02:56

标签: database linq entity-framework

我有像

这样的SQL查询
select * from user where firstname like '%Je%' collate SQL_Latin1_General_CP1_CI_AI 

Linq能做这样的事吗?

我可以使用ExecuteStoreQuery,但想知道Linq是否可以使用它。感谢。

2 个答案:

答案 0 :(得分:0)

法语口音应该没问题

var results = from u in _context.User
          where u.firstname.Contains("é")
          select u

答案 1 :(得分:0)

如何添加应用归类的SQL视图?

例如,

CREATE VIEW UserSearch AS
    SELECT *
        , FirstName collate SQL_Latin1_General_CP1_CI_AI AS FirstNameSearch 
    FROM User

然后你可以做

var results = from us in _context.UserSearch
              where us.FirstNameSearch.Contains("é")
              join u in _context.User on us.UserId equals u.UserId
              select u