开发者

DTOs Collections mapping Problem

开发者 https://www.devze.com 2023-02-03 02:02 出处:网络
I\'m working now on a multi-tier project using .Net which has layers as following : DAL BLL GUI Layer and Shared DTOs between BLL and GUI layers.

I'm working now on a multi-tier project using .Net which has layers as following :

  • DAL
  • BLL
  • GUI Layer

and Shared DTOs between BLL and GUI layers.

I'm facing a problem in mapping the Objects from DAO To DTO, No problem in the simple objec开发者_开发问答ts.

The problem is in the Objects who have child collections of another objects. ex:

Author                      Category
--Categories                --Authors 

the execution goes in an infinite loop of mapping

and it get more complex when I want model Self-join tables ex:

Safe                                    Safe
--TransferSafe(Collection<Safe>)        --TransferSafe(Collection<Safe>)

the execution goes in an infinite loop of mapping

any suggestions about a good solution or a practical mapping pattern?


I don't know what language you're using, but if you're in .NET you can use the very handy AutoMapper. It makes these sorts of things a ton less manual, and helps solve your infinite loop problem.

0

精彩评论

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