I have a list of MyObject objects that look like this:
public class MyObject{ public int FruitID {get;set;} public string FruitName {get;set;} } List<MyObject> TheList = new List<MyObject>();
This list is populated with the linq-to-sql query. I am looking to create a connection between this list and a table containing FruitID as its foreign key.
The HarvestTimes table looks like this:
FruitID | HarvestDatetime | RipeFactor 3 | 3/4/2011 | 2 3 | 4/5/2011 | 4 3 | 5/5/2011 | 3 4 | 3/21/2011 | 2 4 | 4/10/2011 | 2 4 | 5/10/2011 | 2
This is what I still have:
var TheQuery = (from list in TheList join fruit in MyDC.HarvestTimes on list.FruitID equals fruit.FruitID where .... select new MyObject{... }).ToList();
I have problems with the Where clause. How to get only Fruit where RipeFactor is always 2. For example, Fruit 3 has RipeFactor of 2, but also has 4, and only Fruit4 has only 2s. I tried with Contains, but both fruits came up.
Thanks for your suggestions.
c # linq
frenchie
source share