Open Closed

Best Practice on AppService #10025

lweng567 created

Prerequisites Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

What is your product version? 9.3.0 What is your product type (Angular or MVC)? Angular What is product framework type (.net framework or .net core)? .net Core If issue related with ABP Framework What is ABP Framework version? Zero

Hi There,

I am seeking some advice regarding best practice on Appservices. Let say I have an Individual Entity and it has an Employment Entity. User can create an Individual entity and can later create an Employment entity for an existing Individual. So in my application layer, option one) i could create an IndividualAppservice to have a method for creating individual and a method for creating employment. or option two) i could create an IndividualAppservice for creating individual and create an employmentAppservice for creating employment for an existing individual. With option one, i will need to inject two repositories to the appservice, with** option two**, i will just inject one respective repository to each appservice.

My question is how best to construct appservice for parent and child relationship entity

  1. should i use one parent appserivce(option one) or split them into its own appservice(two)
  2. what is the optima number repository or domain manager to be injected


1 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @lweng567

    If you want to call one app service from another in option two, we don't suggest using this approach becasue app services must be representing use cases of the end user applications.

    In your case, if these entities can be used separately, it is better to define two different app services. You can even define a domain service for these two entities and use it in both app services.