从具有相同属性的其他对象创建对象 [英] Creating objects from another object with same properties

查看:142
本文介绍了从具有相同属性的其他对象创建对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中的对象,可以说20的属性,这是一个datacontract的一部分。我也有类似的性质,这是我想从响应对象来填充另一业务实体。有没有办法做到这一点比其他分配一个对象的每个属性其他相应的属性?

I have an object in C# with lets say 20 properties and it's part of a datacontract. I also have another business entity with similar properties, which I want to populate from the response object. Is there any way to do this other than assigning each property of one object to the corresponding properties of the other?

推荐答案

是的,看看<一href="http://www.lostechies.com/blogs/jimmy%5Fbogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx"相对=nofollow> Automapper

这篇关于从具有相同属性的其他对象创建对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆