我的SQL查询需要LINQ [英] Need LINQ for my SQL Query

查看:62
本文介绍了我的SQL查询需要LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以为以下SQL查询编写等效的LINQ



从ProductPrice中选择discountOfferID,其中(2,3,4)

解决方案

试试这个..

  var  strVal =  new   int  [] { 3  4  5 }; 

var resultset = 来自 x in dbContext.ProductPrice 其中 strVal.Contains(x.discountOfferID)选择 new {x.discountOfferID}





查看此链接..

http://stackoverflow.com/questions / 2334327 / what-is-the-linq-equivalent-to-sql-in-operator [ ^ ]


Hi


它将是这样的



来自ProductPrice

其中discountOfferID in(2,3,4)

select discountOfferID



Bechir


H i,



  string  strdiscountOfferID =   1,2,3; 

来自 ProductPrice
其中​​ strdiscountOfferID.Contains(a.discountOfferID)
选择 a.discountOfferID;


Can anyone write the equivalent LINQ for below SQL Query

select discountOfferID from ProductPrice where discountOfferID in (2,3,4)

解决方案

try this..

var strVal= new int[] {3, 4, 5 };

var resultset = from x in dbContext.ProductPrice where strVal.Contains(x.discountOfferID ) select new{x.discountOfferID}



See this link..
http://stackoverflow.com/questions/2334327/what-is-the-linq-equivalent-to-the-sql-in-operator[^]


Hi
it will be like this

from ProductPrice
where discountOfferID in (2,3,4)
select discountOfferID

Bechir


Hi,

string strdiscountOfferID ="1,2,3";

from a in ProductPrice
where strdiscountOfferID.Contains(a.discountOfferID)
select a.discountOfferID;


这篇关于我的SQL查询需要LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆