How to do a LIKE query with linq?

前端 未结 8 1543
予麋鹿
予麋鹿 2020-12-03 02:57

How can i perform an LIKE query within Linq?

I have the following query i would like to execute.

var results = from c in db.costumers
              w         


        
相关标签:
8条回答
  • 2020-12-03 03:23

    You could use SqlMethods.Like(matchExpression,pattern)

    var results = from c in db.costumers
                  where SqlMethods.Like(c.FullName, "%"+FirstName+"%,"+LastName)
                  select c;
    

    The use of this method outside of LINQ to SQL will always throw a NotSupportedException exception.

    0 讨论(0)
  • 2020-12-03 03:25
     where c.FullName.Contains("string")
    
    0 讨论(0)
提交回复
热议问题