M
M
marshinov2013-10-29 01:12:30
.NET
marshinov, 2013-10-29 01:12:30

Dynamic generator Dto

Once again, describing the DTO class, I thought it would be convenient to have a dynamic generator that would build a DTO at the start of the application, like AutoMapper.

We make an Extension method and all Domain.Entity have a ToDto () method, and ToDto - by convention. Think about conventions, for example, if an IEnumerable<Product> is returned, then it is more logical to return a Dto with CategoryId, and not Category: {...}. Well, to destroy circular links. Such functionality in 90% of cases will save you from writing the same classes. At the same time, you can return to lowerCamelCase in java-script.

Is there any solution similar in open source or is it not a sin to write?

The other way around is more difficult, but can also be assembled from dynamic or something like IDto<TEnityType>.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question