質問

????????????????????????????????????????????????????????????????????????????????????????????????????????

????ToList????????????????????????????????????????????

List<Class1>.Except(List<Class2> I need to map class2 list to class1 list)

???

役に立ちましたか?

解決

In LINQ, Select is synonymous with "map" in other languages. It is called "select" because the word comes from database terminology... but Select is what you want:

var mappedTypes = myCollection.Select(item => new MappedType(item.Something));

他のヒント

If you want a projection you can use ye olde Select operator:

list1.Except(list2.Select(x => ConvertToClass1(x));
List<Class1>.Except(List<Class2>.Select(e => 
                                           new Class1() 
                                                    { 
                                                      Field1 = e.Field1 ...
                                                    });

However, I would advise you to use automapper.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top