Back to list
Views:   5.2K
Replies:  1

Why not use DTO?

BusinessObjects from WinForms of Patterns In Action4.5
Why do you need to Mapper.CreateMap work to define the MemberModel / OrderDetailModel / OrderModel from the Model folder?

Sample :
\Patterns in Action\WinFormsApp\Models\Model.cs

Current :
        public MemberModel GetMember(int memberId)
            var member = service.GetMember(memberId);
            return Mapper.Map<Member, MemberModel>(member);

My Coding :  DTO (
        public Member GetMember(int memberId)
            return service.GetMember(memberId);

Why do not use DTO?

Ji Hyeonmyeong, Sep 21, 2015
Reply 1
Hello Ji: 

In our example the Member Business Object is mapped to a Member Model which is a DTO.

In your example the Business object is returned, which may or may not be a DTO (if it has methods it is not considered a DTO).
But if it is a DTO then your example is just fine.  

In fact, if it not a DTO is would also be fine. DTO is a 'best practice' but not absolutely necessary.

Hope this helps.

Jack Poorte, Sep 26, 2015

Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0