Click here to Skip to main content
15,905,229 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Can anyone write the equivalent LINQ for below SQL Query

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

try this..
C#
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[^]
 
Share this answer
 
Hi
it will be like this

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

Bechir
 
Share this answer
 
Hi,

C#
string strdiscountOfferID ="1,2,3";

from a in ProductPrice
where strdiscountOfferID.Contains(a.discountOfferID)
select a.discountOfferID;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900