Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Are data transfer objects (DTO) good practice?

$
0
0

I'm not sure if it's better to create separate models for input and output from my Web API controllers or operating on entities(speaking in EF context) directly.

I can control which properties to serialize using [JsonIgnore] or setting MemberSerialization.OptIn to ignore properties by default and only include what's necessary. 

I currently put data annotations for validation in my entity models, like [Regex] for example (I'm not sure if that's used by Entity Framework core)

What should I do?

for example I have class Person, that would mean I would have had to create other classes like PersonCreateParams, PersonCreateResponse etc.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>