I have a List within a List. I need two compare two properties of the sub_List with a third list.
Classes:
public class Human
{
public string FirstName{ get; set; }
public string LastName{ get; set; }
public List<Clothing> clothings { get; set; }
}
public class Clothing
{
public string ClothingID{ get; set; }
public string Garment{ get; set; }
public string Color{ get; set; }
}
public class CurrentClothes
{
public string Garment{ get; set; }
public string Color{ get; set; }
}
Pseudo Code:
public List<Human> humans = new List<Human>()
{
new Human
{
FirstName="Karl",
LastName="Karlson"
clothings=new List<Clothing>()
{
new Clothing
{
ClothingID="1",
Garment="T-Shirt",
Color="pink"
},
new Clothing
{
ClothingID="11",
Garment="Pant",
Color="white"
},
new Clothing
{
ClothingID="111",
Garment="Shoes",
Color="black"
}
}
},
new Human
{
FirstName="Paula",
LastName="Paulson"
clothings=new List<Clothing>()
{
new Clothing
{
ClothingID="2",
Garment="T-Shirt",
Color="red"
},
new Clothing
{
ClothingID="22",
Garment="Pant",
Color="blue"
},
new Clothing
{
ClothingID="222"
Garment="Shoes",
Color="black"
}
}
}
};
public List<CurrentClothes> currentclothes = new List<CurrentClothes>()
{
new CurrentClothes
{
Garment="Pant",
Color="blue"
},
new CurrentClothes
{
Garment="T-Shirt",
Color="red"
},
new CurrentClothes
{
Garment="Shoes",
Color="black"
}
}
var human = humans.Where(x=>x.clothings.Equals(currentClothes));
The question is, how can I compare if the currentclothes matches some human clothes. Is there any Linq Option?
I have added a Example. In this Example there are two humans. Karl and Paula. The current clothes are defind. Now i want the human how matches the currentclothes. In this case Paula.