本文介绍了相比它具有在其中列出了两份清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类汽车和类模型。该车具有许多特性,如CarId和列表<型号及GT; 。车型已拥有各种属性,如ModelID,肤色,令。我有车(从最终用户推出)呼叫是一个列表,然后我有(从DB)汽车的几组名单称之为B点。 A有车的一个列表,其中为B有车的多个列表,我想这两个模型,包括太比较。

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

对不起,没有说清楚。可以说,
名单A有项目carId = 1和财产模型有两个项目1:ModelId = 1,颜色=黑色,使= 1999 和项目2:ModelId = 3,颜色=白色,使= 2004

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

b名单有2项
carId = 5和模型有两个项目1:ModelId = 2,颜色=蓝色,使= 2000项目2:ModelId = 3,颜色=白色,使= 2010

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和模型有两个项目1:ModelId = 5,颜色=黑色,使= 1999 和项目2:在上面的例子中粗体值ModelId = 9,颜色=灰色,使= 2011

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!

推荐答案

我想你想实现的IEqualityComparer,添加自定义比较函数到模型类

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

这篇关于相比它具有在其中列出了两份清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-24 09:35