LINQ to Entities does not recognize the method 'System.String[] Split(Char[])' method,

前端 未结 6 1979
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 02:17

I am trying to implement a method where the keywords stored in the database for an activity (split by a comma) match the giving string split by a comma.

publ         


        
6条回答
  •  天命终不由人
    2020-12-04 02:19

    Yes you can do it like that:

    public List SearchByMultipleKeyword(string keywords)
    {
        string[] keywordsSeparated = keywords.Split(',');
        var results  = (from a in Entities.TblActivities
                        where keywordsSeparated.Any(keyword => a.Keywords.Contains(keyword))
                        select a).ToList();
        return results;
    }
    

提交回复
热议问题