Abp: ICrudAppService with different Get/GetList DTO models

Created on 20 Apr 2019  路  3Comments  路  Source: abpframework/abp

Currently the ICrudAppService/IAsyncCrudAppService interfaces only allow to have the same DTO model for Get and GetList. However sometimes we may need different DTO models for that, like when we need to have a detailed DTO model (Get) and a basic DTO model (GetList).

This suggestion is based on the best practices for DTO's writings.

My suggestion would be to expand the interface like this:

public interface ICrudAppService<TDetailedEntityDto, TBasicEntityDto, in TKey, in TGetListInput, in TCreateInput, in TUpdateInput>
{
    TDetailedEntityDto Get(TKey id);

    PagedResultDto<TBasicEntityDto> GetList(TGetListInput input);

    TDetailedEntityDto Create(TCreateInput input);

    TDetailedEntityDto Update(Tkey id, TUpdateInput input);

    void Delete(TKey id); 
}

The other interfaces can easily use this interface as base (by supplying the same DTO model for detailed and basic entity) so no code changes for existing code might be required.

I have considered that one could also expand the ICrudAppService with a TDetailedEntityDto GetWithDetails(TKey key) and keep the original TEntityDto Get(TKey key) this way, but I think there is no real use case for that (e.g. where one would need a detailed Get and a basic Get).

abp-framework enhancement

Most helpful comment

I'll have a stab at this over the weekend

All 3 comments

Thanks. That's good. We will work on this.

I'll have a stab at this over the weekend

Okay I've done the interfaces I need to change

  • [ ] CrudAppService
  • [ ] AsyncCrudAppService
  • [ ] I may need to change the CrudAppserviceBase - what do you think?

Are there any Unit test for these services?

Was this page helpful?
0 / 5 - 0 ratings