Domain Services | Documentation Center (2024)

Introduction

In a Domain Driven Design (DDD) solution, the core business logic is generally implemented in aggregates (entities) and the Domain Services. Creating a Domain Service is especially needed when;

  • You implement a core domain logic that depends on some services (like repositories or other external services).
  • The logic you need to implement is related to more than one aggregate/entity, so it doesn't properly fit in any of the aggregates.

ABP Domain Service Infrastructure

Domain Services are simple, stateless classes. While you don't have to derive from any service or interface, ABP Framework provides some useful base classes and conventions.

DomainService & IDomainService

Either derive a Domain Service from the DomainService base class or directly implement the IDomainService interface.

Example: Create a Domain Service deriving from the DomainService base class.

using Volo.Abp.Domain.Services;namespace MyProject.Issues{ public class IssueManager : DomainService { }}

When you do that;

  • ABP Framework automatically registers the class to the Dependency Injection system with a Transient lifetime.
  • You can directly use some common services as base properties, without needing to manually inject (e.g. ILogger and IGuidGenerator).

It is suggested to name a Domain Service with a Manager or Service suffix. We typically use the Manager suffix as used in the sample above.

Example: Implement the domain logic of assigning an Issue to a User

public class IssueManager : DomainService{ private readonly IRepository<Issue, Guid> _issueRepository; public IssueManager(IRepository<Issue, Guid> issueRepository) { _issueRepository = issueRepository; } public async Task AssignAsync(Issue issue, AppUser user) { var currentIssueCount = await _issueRepository .CountAsync(i => i.AssignedUserId == user.Id); //Implementing a core business validation if (currentIssueCount >= 3) { throw new IssueAssignmentException(user.UserName); } issue.AssignedUserId = user.Id; } }

Issue is an aggregate root defined as shown below:

public class Issue : AggregateRoot<Guid>{ public Guid? AssignedUserId { get; internal set; } //...}
  • Making the setter internal ensures that it can not directly set in the upper layers and forces to always use the IssueManager to assign an Issue to a User.

Using a Domain Service

A Domain Service is typically used in an application service.

Example: Use the IssueManager to assign an Issue to a User

using System;using System.Threading.Tasks;using MyProject.Users;using Volo.Abp.Application.Services;using Volo.Abp.Domain.Repositories;namespace MyProject.Issues{ public class IssueAppService : ApplicationService, IIssueAppService { private readonly IssueManager _issueManager; private readonly IRepository<AppUser, Guid> _userRepository; private readonly IRepository<Issue, Guid> _issueRepository; public IssueAppService( IssueManager issueManager, IRepository<AppUser, Guid> userRepository, IRepository<Issue, Guid> issueRepository) { _issueManager = issueManager; _userRepository = userRepository; _issueRepository = issueRepository; } public async Task AssignAsync(Guid id, Guid userId) { var issue = await _issueRepository.GetAsync(id); var user = await _userRepository.GetAsync(userId); await _issueManager.AssignAsync(issue, user); await _issueRepository.UpdateAsync(issue); } }}

Since the IssueAppService is in the Application Layer, it can't directly assign an issue to a user. So, it uses the IssueManager.

Application Services vs Domain Services

While both of Application Services and Domain Services implement the business rules, there are fundamental logical and formal differences;

  • Application Services implement the use cases of the application (user interactions in a typical web application), while Domain Services implement the core, use case independent domain logic.
  • Application Services get/return Data Transfer Objects, Domain Service methods typically get and return the domain objects (entities, value objects).
  • Domain services are typically used by the Application Services or other Domain Services, while Application Services are used by the Presentation Layer or Client Applications.

Lifetime

Lifetime of Domain Services are transient and they are automatically registered to the dependency injection system.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

Domain Services | Documentation Center (2024)

FAQs

What is the role of aad dc administrators? ›

A special administrative group named AAD DC Administrators is used for management of the Domain Services domain. Members of this group are granted administrative permissions on VMs that are domain-joined to the managed domain. On domain-joined VMs, this group is added to the local administrators group.

What is the DC in Active Directory? ›

Active Directory is a framework that manages several Windows server domains. In contrast, a domain controller is a server on Active Directory to authenticate users based on centrally stored data. Each Active Directory forest can have multiple domains.

What is Azure AD DS used for? ›

Microsoft Entra Domain Services (formerly Azure Active Directory Domain Services), part of Microsoft Entra, enables you to use managed domain services—such as Windows Domain Join, group policy, LDAP, and Kerberos authentication—without having to deploy, manage, or patch domain controllers.

What do domain services do? ›

Domain Services stores centralized directory information and lets users and domains communicate. When a user attempts to connect to a device or resource on a network, this service provides login authentication, verifying the user's login credentials and access permissions.

Is aad a domain controller? ›

It's common to think that the terms Active Directory and domain controller are synonymous. This is because domain control is a function within Microsoft's Active Directory, and domain controllers are servers that leverage AD to validate and respond to authentication requests. However, the terms are not interchangeable.

What is the difference between AAD and Azure roles? ›

Azure AD roles are used to manage access to Azure AD resources, whereas Azure roles are used to manage access to Azure resources.

What is difference between AD and DC? ›

The main difference between a Domain Controller and an Active Directory, is that an Active Directory (AD) manages your identity and gives secure access while Domain Controllers verify your authority. Consider this example: To log in to your computer, you must first verify your identity and establish your authority.

Is a DC an LDAP server? ›

Domain Controller Default

By default Domain Controller(s) listen over LDAP but not LDAPS. They do however still have an active socket listening on the LDAPS port (TCP 636) but by default, this does not function correctly.

What does DC mean in LDAP? ›

The moniker "cn" means Common Name. Similarly, the moniker "dc" means domain component. The component "dc=MyDomain" is a domain component with the name "MyDomain".

What replaced Active Directory? ›

The names Azure Active Directory, Azure AD, and AAD are replaced with Microsoft Entra ID. Microsoft Entra is the name for the product family of identity and network access solutions. Microsoft Entra ID is one of the products within that family.

What is the difference between AD DS and aad DS? ›

AD DS provides a centralized management console called Active Directory Users and Computers (ADUC) to manage users, groups, and computers. It also provides Group Policy to manage security policies. AAD DS provides management through the Azure portal and integrates with various cloud services.

Is A domain controller a server? ›

A domain controller is a server that responds to authentication requests and verifies users on computer networks. Domains are a hierarchical way of organizing users and computers that work together on the same network. The domain controller keeps all of that data organized and secured.

Is GoDaddy a domain service? ›

Get the perfect domain — even if it's not available.

From startups to Fortune 100 companies, GoDaddy is the leading domain broker worldwide.

What is an example of a domain service? ›

They usually operate on multiple domain objects or perform complex calculations or validations. For example, a domain service could be responsible for transferring money between two accounts, checking the availability of a product, or generating a unique identifier for a customer.

What is the difference between a server and a DC? ›

A server is a computer or application that provides services to other devices or applications (its clients). An Active Directory domain controller is a particular type of server — one that runs the Windows Server operating system and has AD DS installed on it.

What is DC and ADC stands for? ›

DC: Domain ControllerADC: Active Directory Integrated Domain ControllerIn DC the zone database is stored in . dns text file where as in ADC the zone database is stored in active directory itself not in .

What is DC in computer? ›

(1) (Direct Current) An electrical current that travels in one direction and used within the computer's electronic circuits. Contrast with AC. (2) (Data Communications) See DB/DC.

What is DC agent on my computer? ›

DC Agent is a Websense transparent identification agent used in networks that authenticate users with a Windows directory service. It mainly does the following: Offers transparent user identification for users in a Windows-based directory service.

Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 6093

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.