Use IN Keyword in Linq Queue

Posted by arvind_gupta87outlook-19425 under C# on 12/5/2012 | Points: 10 | Views : 2897 | Status : [Member] | Replies : 4
How to use IN keyword in Linq Queue?

Like
select * from tablename
where columnname in (1,2,3,4)

but in Linq Queue, What is the syntax of using IN keyword?




Responses

Posted by: Sandhyab on: 12/5/2012 [Member] Starter | Points: 25

Up
0
Down
Once Go through This. This may help you,
http://www.ginktage.com/2011/08/linq-equivalent-of-sqls-in-keyword/

Thanks & Regards

arvind_gupta87outlook-19425, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 12/6/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this,

var Query = from usr in db.users
where new[] { "Admin", "User", "Guest" }.Contains(usr.Table_Rights)
select usr;
foreach (user u in Query)
{
// Do your stuff on each selected user;
}


arvind_gupta87outlook-19425, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 12/6/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi @Arvind_Gupta87
plz Mark As Answer if post will helps you.

arvind_gupta87outlook-19425, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kundnani.Rt on: 1/19/2013 [Member] Starter | Points: 25

Up
0
Down
Example for using IN in LINQ

var result = from items in db.ItemsDetails

where items.SalesID == 75144
select items.ProductID;


arvind_gupta87outlook-19425, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response