سؤال

I want to map my Entities list to DTO list without associations to other DTO's.

For example: http://mysite.local/api/documents returns list of DocumentDTO,

but request to http://mysite.local/api/documents/DA49BC12-CFAB-496A-B3D9-A26200F3E76C returns detailed DocumentDTO object with associations, child objects.

Perhaps I should define two DTO's for my Document entity? (DocumentListItemDTO, DocumentDetailDTO). Or I can partial map my entity to dto with AutoMapper?

هل كانت مفيدة؟

المحلول

You can use odata also to only select the fields you need like http://mysite.local/documents?$select=Id,Name

But if you really want that list objects are different then detail objects i guess it should be different objects.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top