DTOs Collections mapping Problem
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.
精彩评论