我用大量的 ORM工具在过去的NHibernate , Tiers , LLBLGEN 多,他们总是做映射数据pretty做好从数据库到code对象。
I've used plenty of ORM tools in the past, NHibernate, Tiers, LLBLGen and more and they always do a pretty good job of mapping data from a database to objects in code.
我要找的,虽然是一个框架或图案或东西,让我从一个类型的对象转换到另一个。
What I'm looking for though is a framework or a pattern or something that will allow me to transform objects from one type to another.
一个例子是我有两个Web服务,人们投资的另一个有成员。我想通过定义一组投资者的属性映射到成员属性,然后再返回规则的投资者对象转换为成员对象。
An example is I have a two web services, one has Investors another has Members. I want to convert an Investor object to a Member object by defining a set of rules that maps the Investor properties to the Member properties and back again.
NHibernate的映射是最接近我能到这样做,但似乎只针对数据库的工作 - >对象映射。我想知道是否有人知道,让我做任何obejct产品 - >对象映射
NHibernate mappings are the closest I can get to doing this, but it only seems to work for Database -> Object mappings. I was wondering if anyone knew of any products that allowed me to do obejct -> object mapping?
推荐答案您正在寻找AutoMapper
You are looking for AutoMapper
HTTP://automapper.$c$cplex/
更多推荐
对象对象映射器
发布评论