user570715
user570715

Reputation: 639

Comparing two lists which has lists within them

I have a class Cars and class Models. Car has many properties such as CarId and List<Models>. Models has has various properties such as ModelID, Color, Make. I have one list of Cars(coming from end user) call is A and then I have few sets lists of Cars(from DB) call it B . A has one list of Car where as B has multiple lists of Car, I want to compare these two including Models too.

I tried using Except but that does not seem to be working

Sorry for not being clear. lets say list A has item carId = 1 and property Model has two items 1: ModelId =1, color = black, make = 1999 and items 2: ModelId =3, color = white, make = 2004

list B has 2 items carId = 5 and Model has two items 1: ModelId =2, color = blue, make = 2000 and items 2: ModelId =3, color = white, make = 2010

carId = 7 and Model has two items 1: ModelId =5, color = black, make = 1999 and items 2: ModelId =9, color = grey, make = 2011

in above example bolded values should be produced by comparer which I will store into new list. appreciate help. thanks!

Upvotes: 0

Views: 114

Answers (1)

Michiel van Vaardegem
Michiel van Vaardegem

Reputation: 2035

I think you want to implement the IEqualityComparer, to add a custom compare function to your Models class

Upvotes: 1

Related Questions