【发布时间】:2018-04-01 09:54:18
【问题描述】:
如何将此 SQL 查询转换为 Linq? 有一个我无法转换的 not in 语句。
SQL
Select keyword from SW_TBL_KEYWORD
where keyword_scope='A' and
keyword not in ('ATRF', 'CAST','EVAL', 'FTBS', 'KYCB', 'RCAN', 'RDPT','REGA', 'REGC' )
灵巧
public static IEnumerable<SelectListItem> GetProductName()
{
using (WALLET_CORE_UATEntities _ent = new WALLET_CORE_UATEntities())
{
return new SelectList(_ent.SW_TBL_KEYWORD.Where(x => x.Keyword_Scope == "A" && x.Keyword!= "ATRF"
&& x.Keyword!= "CAST"
&& x.Keyword != "EVAL"
&& x.Keyword != "FTBS"
&& x.Keyword != "KYCB"
&& x.Keyword != "RCAN"
&& x.Keyword != "RDPT"
&& x.Keyword != "REGA"
&& x.Keyword != "CAST"
&& x.Keyword != "REGC")
.ToList(),"Keyword","Keyword_Description");
}
}
【问题讨论】:
-
我撤回了我的重复投票;这个问题与另一个问题相反。
标签: .net model-view-controller