Abp: Introduce read-only app service

Created on 9 Jun 2020  路  6Comments  路  Source: abpframework/abp

I am wondering if it might be nice to introduce a IReadOnlyAppService which is similar to CrudAppService but excludes:

  • CreateAsync
  • UpdateAsync
  • DeleteAsync

The reason is that sometimes there are cases where we may only want to read via the API, but the updating happens somewhere else like another service.

In my case I have a 'Policy' which has sub-types like 'SimplePolicy' and 'ScheduledPolicy' which have their own 'update' and 'create' functionality, but share common set of 'Policy' properties and I want to be able to 'get' their high level properties.
Right now I will have to re-implement all the features from the CrudAppService and exclude these 3 endpoints, because the class is templated and I don't have the CRUD Dto's on the base class.

abp-framework feature

Most helpful comment

Kudos should go to @hikalkan and volosoft ;-)

All 6 comments

I would even consider going further and splitting the ICrudAppService interface into more fine grained interfaces like ICreateAppService, IUpdateAppService, ICreateUpdateAppService and IDeleteAppService and combine them in the ICrudAppService interface.

Use-case: I'm planning to implement some kind of glue to use application services in generic ViewModel classes (by using the DevExpress MVVM framework) to be used in WinForms (and maybe more platforms). But this task required further changes. One constraint I'm experiencing is that the GetOutputDto and GetListOutputDto can differ and aren't related (GetOutputDto : GetListOutputDto [GetOutputDto mustn't be assignable to GetListOutputDto]). So when designing interfaces and base viewmodels, a Task<GetListOutputDto> GetListItemAsync(TKey id); would help me a lot. But the GetListItemAsync method is something, I can resolve by myself on my application services.

I agree with @NecatiMeral
I added to backlog. Any PR would be appreciated.

Which package should I install to use ReadOnlyAppService?
I updated from abp v2.8.0 to the latest v2.9.0 using CLI command abp update from the folder containing .sln file.
But when I extend ReadOnlyAppService to create my own Service, VS reports that The type or namespace ReadOnlyAppService could not be found.

Thanks and best regards

I'll be released in 3.0.0 (which will be release very soon).

I'll be released in 3.0.0 (which will be release very soon).

Yeah. This ReadOnlyAppService is exactly what I've thinked of before. Will wait for it.
Thank you guys very much for making an excellent framework.

Kudos should go to @hikalkan and volosoft ;-)

Was this page helpful?
0 / 5 - 0 ratings