Linq to SQL“不喜欢"操作员 [英] Linq to SQL "not like" operator
本文介绍了Linq to SQL“不喜欢"操作员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的SQL语句.
I have a simple SQL statement.
从表名中选择与%TEST%"不同的值
Select distinct value from tablename where value not like '%TEST%'
如何用Linq编写SQL语法.
How do I write this in Linq to SQL syntax.
我尝试了以下语句,但似乎不起作用.
I tried the below statement but it doesnt seem to work.
var p = (from c in tablename where !(c.value.ToUpper().Contains("%TEST%"))
select c.Value).Distinct().ToList()
推荐答案
问题是%"-您正在寻找的东西实际上不包含%TEST%",而这可能就是一切.我想你是说:
The problem is the "%" - you're looking for things which literally don't contain "%TEST%" which would probably be everything. I think you mean:
var p = (from c in tablename
where !c.Value.ToUpper().Contains("TEST")
select c.Value).Distinct().ToList()
这篇关于Linq to SQL“不喜欢"操作员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文