AUA Framework Training — Episode 8

Adding Service & New Entity (Part 3)

Mastering Built-in Repositories, Service Types, and Asynchronous Operations in AUA

Watch Video on YouTube

Services & Built-in Repositories

All business logic in the AUA framework is implemented via services within the service layer. The service layer leverages the Service Infrastructure layer, automatically connecting each service to its respective repository. This isolates developers from manual repository-service wiring so they can focus strictly on core business rules.

For instance, implementing a service for the Student entity requires:

  1. Creating an interface for the Student entity inheriting from IGenericEntityService.
  2. Creating the concrete service class under the Services directory.
  3. Inheriting from GenericEntityService and implementing your custom business interface. All standard repository functions are added automatically!

Service Categories in AUA Framework

The framework provides specialized service types tailored for every application layer and requirement:

Entities Service

Built-in repository support for entity CRUD operations and entity-specific business logic.

Business Service

Dedicated for custom application business rule implementations.

General Service

Cross-cutting application services such as login handling and JWT token generation.

List Service

Optimized for fast operational reporting and data listings.

Report Service

Complex enterprise reporting service configurations.

SQL Function Service

Seamless access to database SQL functions and stored procedures.

Validation Service

Validating incoming view models and payloads sent by clients.

Log Service

Centralized logging capabilities across operations.

InMemory / Views / External

Handlers for in-memory data caches, SQL views, and third-party external service integration providers.

Execution Formats

All primary entity service functions are natively available in three flexible execution forms:

1. Asynchronous
2. Synchronous
3. Async with CancellationToken

Entity Configurations & EF Core Fluent API Patterns

EntityConfigs.cs

Each entity in AUA can have a dedicated configuration class implementing IEntityTypeConfiguration<T> to manage property lengths, composite keys, non-identity keys, and global query filters.

1. Property Constraints & Lengths StudentConfig.cs
public class StudentConfig : IEntityTypeConfiguration<Student>
{
    public void Configure(EntityTypeBuilder<Student> builder)
    {
        builder.Property(p => p.FirstName)
               .HasMaxLength(LengthConsts.MaxStringLen50);

        builder.Property(p => p.LastName)
               .HasMaxLength(LengthConsts.MaxStringLen50);
    }
}
2. Composite Primary Key Mapping UserRoleConfig.cs
public class UserRoleConfig : IEntityTypeConfiguration<UserRole>
{
    public void Configure(EntityTypeBuilder<UserRole> builder)
    {
        // Ignore standard single Id property
        builder.Ignore(p => p.Id);

        // Configure combined composite primary key
        builder.HasKey(p => new { p.AppUserId, p.RoleId });
    }
}
3. Non-Identity Key Explicit Assignment UserAccessConfig.cs
public class UserAccessConfig : IEntityTypeConfiguration<UserAccess>
{
    public void Configure(EntityTypeBuilder<UserAccess> builder)
    {
        // Disables identity generation to pass custom primary key values
        builder.Property(p => p.Id)
               .ValueGeneratedNever();

        builder.Property(p => p.Title)
               .HasMaxLength(LengthConsts.MaxStringLen300);

        builder.Property(p => p.IsActive)
               .IsRequired();
    }
}
4. Global Query Filter (Soft Delete) AppUserConfig.cs
public class AppUserConfig : IEntityTypeConfiguration<AppUser>
{
    public void Configure(EntityTypeBuilder<AppUser> builder)
    {
        // Automatically excludes soft-deleted records from EF Core queries
        builder.HasQueryFilter(p => !p.IsDeleted);
    }
}
“
”
"If you think good architecture is expensive, try bad architecture."
AUA Framework Philosophy

Official Channels & Community

Connect with the AUA Framework ecosystem.

Episode 8 Completed Service Actions