NeuCharFramework (NCF)
  • NCF - NeuCharFramework
  • Projects

    • Preparation
    • NcfPackageSources Source Guide
    • DynamicWebApiEngine
    • Deployment
  • Help

    • Online Resources
    • Q&A Community
    • QQ Group (147054579)
    • Senparc WeChat SDK
  • Gitee
  • GitHub
  • English
  • 简体中文
GitHub
  • NCF - NeuCharFramework
  • Projects

    • Preparation
    • NcfPackageSources Source Guide
    • DynamicWebApiEngine
    • Deployment
  • Help

    • Online Resources
    • Q&A Community
    • QQ Group (147054579)
    • Senparc WeChat SDK
  • Gitee
  • GitHub
  • English
  • 简体中文
GitHub
  • Quickstart And Capability Guide

    • NcfPackageSources Beginner Quickstart (60 Minutes)
    • NcfPackageSources Source Guide
    • NCF Capability Deep Dive (Practical)
    • Version Upgrade Notes
  • XNCF Extension Modules

    • XNCF Extension Library Guide (Senparc.Xncf.xxx)
  • NCF Libraries

    • Senparc.Ncf.Core
    • Senparc.Ncf.Database (Database Foundation)
    • Senparc.Ncf.Repository
    • Senparc.Ncf.Service
    • Senparc.Ncf.SMS
    • Senparc.Ncf.Mvc.UI
    • Senparc.Ncf.Log
    • Senparc.Ncf.Utility
    • Senparc.Ncf.XncfBase
    • Senparc.Ncf.AreaBase
    • Senparc.Ncf.DatabasePlant
  • Core Interfaces

    • IXncfRegister Interface (Current)

Senparc.Ncf.Service

Positioning

Senparc.Ncf.Service is the business-service layer above Repository. It provides transaction orchestration, mapping support, and cross-repository composition as the recommended location for domain/application logic.

Key Types

  • IServiceBase<T>
  • ServiceBase<T>
  • ServiceDataBase
  • DtoServiceBase
  • ResilientTransaction

Core folders: ServiceBase, System, Common

Core APIs

  • GetObjectAsync / GetObjectListAsync / GetFullListAsync
  • SaveObjectAsync / DeleteObjectAsync / SaveObjectListAsync
  • BeginTransactionAsync(...) / CommitTransaction() / RollbackTransaction()
  • Mapping<TDto>(entity)
  • SetTenantInfo(RequestTenantInfo)

Recommended Pattern

public class DemoService : ServiceBase<DemoEntity>
{
    public DemoService(IServiceProvider serviceProvider) : base(serviceProvider)
    {
    }

    public async Task<DemoEntity> GetByCodeAsync(string code)
    {
        return await GetObjectAsync(x => x.Code == code);
    }
}

Division of Responsibilities

  • Repository: generic persistence primitives.
  • Service: business rules, transaction boundaries, cross-repository workflows, DTO mapping.

Recommendations

  • Keep business logic in services, not in controllers/app-services.
  • Make multi-step writes explicitly transactional.
  • Validate tenant context early when handling tenant-isolated data.
Edit this page on GitHub
Last Updated:
Contributors: Jeffrey Su, JeffreySu
Prev
Senparc.Ncf.Repository
Next
Senparc.Ncf.SMS