Last post May 29, 2011 12:52 PM by maltesehunter
May 29, 2011 11:39 AM|maltesehunter|LINK
I am trying to figure out how to replicate this sql query in linq: "SELECT ID FROM Imgs WHERE AlbumID IN(1, 2, 3)"
I have been researching and have not found a clear example.
Linqdatasource1.Where = "AlbumID.Contains(""1, 2, 3"")" shows no results??? I am a little unsure about this. If I select one value such as 1 it works ok, but if I select multiple values it raises error. It is straight forward w/ sql but not so much with
linq- thanks, jake
May 29, 2011 11:48 AM|tehremo|LINK
I think you have it backwards. AlbumID is a single value (I assume), so Contains would never work on it. Switch them around:
List<int> ids = new List<int>():
May 29, 2011 12:36 PM|maltesehunter|LINK
I am trying to do exactly what the sql query I posted in linq. I want to find all the ids from the img table where the albumID = 1, 2, 3. I do not see how your example would work.
May 29, 2011 12:52 PM|maltesehunter|LINK
I figured it out with this link: http://mstecharchitect.blogspot.com/2009/01/linq-to-sql-in-operator.html