标签:ef automapper object to object
在实际的软件开发项目中,我们的“业务逻辑”常常需要我们对同样的数据进行各种变换。例如,一个Web应用通过前端收集用户的输入成为Dto,然后将Dto转换成领域模型并持久化到数据库中。另一方面,当用户请求数据时,我们又需要做相反的工作:将从数据库中查询出来的领域模型以相反的方式转换成Dto再呈现给用户。有时候我们还会面临更多的数据使用需求,例如有多个数据使用的客户端,每个客户端都有自己对数据结构的不同需求,而这也需要我们进行更多的数据转换。 频繁的数据转换琐碎而又凌乱,很多时候我们不得不:| BookStoreDto中的字段 | BookStore中的字段 |
| Name | Name |
| Books | Books |
| Address | Address |
| AddressDto中的字段 | Address中的字段 |
| Country | Country |
| City | City |
| Street | Street |
| PostCode | PostCode |
| BookDto中的字段 | Book中的字段 |
| Title | Title |
| Description | Description |
| Language | Language |
| Price | Price |
| PublishDate | PublishDate |
| Paperback | Paperback |
| BookDto中的字段 | Book中的Authors中的第1个Author对象中的字段 |
| FirstAuthorName | Name |
| FirstAuthorDescription | Description |
| FirstAuthorEmail | ContactInfo.Email |
| FirstAuthorBlog | ContactInfo.Blog |
| FirstAuthorTwitter | ContactInfo.Twitter |
| BookDto中的字段 | Book中的Authors中的第2个Author对象中的字段 |
| SecondAuthorName | Name |
| SecondAuthorDescription | Description |
| SecondAuthorEmail | ContactInfo.Email |
| SecondAuthorBlog | ContactInfo.Blog |
| SecondAuthorTwitter | ContactInfo.Twitter |
| BookDto中的字段 | Publisher中的字段 |
| Publisher | Name |
使用AutoMapper实现Dto和Model的自由转换(上)
标签:ef automapper object to object
原文地址:http://blog.csdn.net/zhanghongjie0302/article/details/42245503