Wednesday, 11 January 2012

Linq syntax for sql's not in and in

For In here how it goes
   var Userlist = new List<Int32> { 560, 561, 511, 611 };
   var User= context.GetTable<Users>();
   var q = (from p in User where Userlist.Contains(p.int_UserId) select p);

For Not In here how it goes
   var Userlist = new List<Int32> { 560 };
   var User= context.GetTable<Users>();
   var q = (from p in User where !Userlist.Contains(p.int_UserId) select p);

No comments:

Post a Comment