How To Use DTOs In .NET REST APIs

How To Use DTOs In .NET REST APIs

Julio Casal

1 год назад

15,814 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@podeig
@podeig - 20.11.2023 18:48

Super tutorial, Easy explained and precisely what I needed. Thank you!

Ответить
@failscript
@failscript - 08.09.2023 21:28

By C# conventions you should use "toDTO" instead of "asDTO" since the method returns a new object. The "as" word is used for when you want to imply that something is being casted AS something.

Ответить
@saddamhossaindotnet
@saddamhossaindotnet - 08.09.2023 08:50

Great tutorial! Is it possible to utilize extension methods for complex DTO mapping without any external libraries? Do you consistently employ extension methods for DTOs without relying on any other mapping libraries?

Ответить
@faridulhuk1248
@faridulhuk1248 - 26.08.2023 18:10

Is it possible to create Mapper for Mapping dto to Entity , reverse way

Ответить
@josecarlosmacoratti
@josecarlosmacoratti - 30.07.2023 16:37

Great !!! Using extension methods is the best way in a simple scenario .

Ответить
@agat366
@agat366 - 14.06.2023 13:09

From my long experience, it’s quite inconvenient and time-consuming to define all the transformations. Imagine if you have several dozens of DTOs, also, it’s inconvenient as you have to make all the transformations changes manually after refactoring. I believe, more standard approach is auto-mapping. The only thing I would consider would be embedding AutoMapper into the AsDto extension methods.

Ответить
@somaticHuman
@somaticHuman - 14.06.2023 00:09

I prefer to use user-defined explicit conversion operators inside DTOs, instead of extension methods...

Ответить
@redouane5626
@redouane5626 - 13.06.2023 18:23

I have habit that I do not use DTOs for API return types, instead I call them Models, is this right or wrong?

Ответить