natural born programmer

Blog Archive

  • ►  2020 (4)
    • ►  February (4)
  • ►  2019 (1)
    • ►  June (1)
  • ►  2015 (15)
    • ►  March (2)
    • ►  February (2)
    • ►  January (11)
  • ►  2012 (4)
    • ►  July (2)
    • ►  February (2)
  • ▼  2011 (11)
    • ►  December (1)
    • ▼  October (2)
      • in queries from sql to linq
      • sql error in changing a db structure and saving again
    • ►  September (1)
    • ►  July (7)
  • ►  2010 (2)
    • ►  March (2)
  • ►  2009 (3)
    • ►  December (3)
  • ►  2008 (3)
    • ►  November (1)
    • ►  August (1)
    • ►  June (1)

About Me

My photo
PD
View my complete profile

Thursday, October 27, 2011

in queries from sql to linq

try this:

List Ids = new List;
Ids.Add(1);
Ids.Add(2);
Ids.Add(3);

var t = from n in productList
where Ids.Contains(n.Id)
select n;

this is like:

select * from productList where Id in (1, 2, 3)
Posted by PD at 12:26 AM

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)