问题描述
YouhaveaList<int>containingProductIDsand,usingLinqtoEntities,youwanttoretrieverecordfromtheProductstablewhichmatchthoseIDs.NametwomethodsyoucoulduseinaWhereclausetoachievethisresult.Whichoneofthesemethodswouldyouactuallyuseandwhy?
解决方案
解决方案二:
顶,大牛回答下
解决方案三:
去百度翻译。。。
解决方案四:
List<int>results=(fromainProductswherea.IDs>5).ToLists();
解决方案五:
List<int>results=(fromainProductswherea.IDs>5selecta.IDs).ToLists();
解决方案六:
List<int>productIds=newList<int>{1,2,3,4,5};varresutls=frompinproductswhereproductIds.Contain(p.ProductId)selectp;CannotfigureouttheothermethodtousedintheWhereclause.
解决方案七:
Products.where(m=>productIds.contains(m.productId));
解决方案八:
actually,thereare:List<int>productIds=newList<int>{1,2,3,4,5};varq1=frompinproductswhereproductIds.Contains(p.ProductId)selectp;varq2=frompinproductswhereproductIds.Any(x=>x==p.ProductId)selectp;IpreferuseContains