How to deep copy between objects of different types in C#.NET

前端 未结 7 1252
孤街浪徒
孤街浪徒 2020-12-06 01:55

I have a requirement to map all of the field values and child collections between ObjectV1 and ObjectV2 by field name. ObjectV2 is in a different namspace to ObjectV1.

7条回答
  •  既然无缘
    2020-12-06 02:57

    If speed is an issue you could take the reflection process offline and generate code for the mapping of the common properties. You could do this at runtime using Lightweight Code Generation or completely offline by building C# code to compile.

提交回复
热议问题