I am having trouble efficiently selecting the information I need to display. Hopefully someone else has a better idea of how to solve this.
Given the following data structures,
public class Department
{
public int ID { get; set; }
public string Name { get; set; }
public IList<Product> Products{ get; set; }
}
public class Product
{
public int ID { get; set; }
public string Name { get; set; }
}
And given the following data
Department1 =
{
Id=1,
Name="D1",
Products = {new Product{Id=1, Name="Item1"}, new Product{Id=2, Name="Item2"}
}
Department2 =
{
Id=2,
Name="D2",
Products = {new Product{Id=2, Name="Item2"}, new Product{Id=3, Name="Item3"}
}
How do I select out that "Item2" is common to both "D1" and "D2"?
I have tried using an intersection query, but it appears to want two deferred query execution plans to intersect rather than two IEnumerable lists or ILists.
Any help with this is greatly appreciated.
Edit: It appears I wasn't very precise by trying to keep things simple.
I have a list of departments, each contain a list of products. Given these lists, how do I select another list of products based on a particular criteria. My criteria in this instance is that I want to select only products that exist in all of my departments. I want only the data that intersects all elements.