开发者

Deep copy objects from different namespaces

开发者 https://www.devze.com 2022-12-29 22:49 出处:网络
I have the following situation: I have class User with the follwing properies : public class User { string user name ;

I have the following situation: I have class User with the follwing properies :

public class User
{
 string user name ;
 List <Contact> contacts ;
 List <BookMark> book marks;
 .
 .
 .
}

I have the same class in a different namespace , with some different properties . BWT , it's the same situation of it's classes (Contact) and (BookMark). I need to make a deep copy of the same properties from the two classes .

Actually , I arrive to this situation by having an Entity Framework edmx file . I created the first database (SQL server 2008) from this model . And copied he same edmx file to another project and created the database with SQL CE db. Now I get the first data model objects by WCF service and need to persist them in the local database in my application .开发者_如何学Python The objects are the same but there are some changs because of the modeling issue with a different databse. Do you have any workarround about this assue.

Thanks in advance ...


Try automapper http://automapper.codeplex.com/


I think I'd write my own deepcopy method that could use reflection to inspect what fields of object to copy.

0

精彩评论

暂无评论...
验证码 换一张
取 消