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
where c.FullName LIKE "%"+FirstName+"%,"+LastName
select c;
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.
这篇关于如何使用 linq 进行 LIKE 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!