Healnet.Core 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Healnet.Core --version 1.0.2
                    
NuGet\Install-Package Healnet.Core -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Healnet.Core" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Healnet.Core" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Healnet.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Healnet.Core --version 1.0.2
                    
#r "nuget: Healnet.Core, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Healnet.Core@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Healnet.Core&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Healnet.Core&version=1.0.2
                    
Install as a Cake Tool

Healnet.Core

Healnet.Core 是 Healnet 框架的核心业务层类库,提供领域层的基础接口和通用服务。

功能特性

  • 仓储接口 (IRepository<TEntity, TKey>) - 定义完整的数据访问操作接口
  • 工作单元 (IUnitOfWork) - 提供事务管理支持
  • 服务接口 (IService) - 定义业务服务基类接口
  • 缓存服务 (ICacheService) - 定义缓存操作接口
  • 消息发布/订阅 (IMessagePublisher/IMessageSubscriber) - 定义消息队列接口
  • 异常类型 - 提供统一的业务异常处理

安装

Install-Package Healnet.Core

使用示例

IRepository

public class UserService
{
    private readonly IRepository<User, long> _userRepository;
    
    public UserService(IRepository<User, long> userRepository)
    {
        _userRepository = userRepository;
    }
    
    public async Task<User> CreateUserAsync(UserCreateDto dto)
    {
        var user = new User
        {
            Name = dto.Name,
            Email = dto.Email,
            Password = HashPassword(dto.Password)
        };
        
        return await _userRepository.AddAsync(user);
    }
    
    public async Task<User> UpdateUserAsync(long id, UserUpdateDto dto)
    {
        var user = await _userRepository.GetByIdAsync(id);
        if (user == null) throw new NotFoundException("User not found");
        
        user.Name = dto.Name;
        user.Email = dto.Email;
        
        return await _userRepository.UpdateAsync(user);
    }
}

IUnitOfWork

public async Task ProcessOrderAsync(Order order)
{
    using var unitOfWork = _unitOfWorkFactory.Create();
    
    try
    {
        await _orderRepository.AddAsync(order);
        await _inventoryRepository.UpdateStockAsync(order.Items);
        
        await unitOfWork.CommitAsync();
    }
    catch
    {
        await unitOfWork.RollbackAsync();
        throw;
    }
}

异常处理

try
{
    var user = await _userRepository.GetByIdAsync(userId);
    if (user == null)
    {
        throw new NotFoundException("User not found");
    }
    
    if (!user.IsActive)
    {
        throw new BusinessException("User is inactive");
    }
}
catch (NotFoundException ex)
{
    // 处理资源未找到异常
}
catch (BusinessException ex)
{
    // 处理业务逻辑异常
}

命名空间

using Healnet.Core.Interfaces;
using Healnet.Core.Services;
using Healnet.Core.Exceptions;
using Healnet.Core.Entities;
using Healnet.Core.Responses;

许可证

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Healnet.Core:

Package Downloads
Healnet.Infrastructure

Healnet.Infrastructure 是 Healnet 框架的基础设施层类库,提供各种基础设施服务的封装和集成,包括 Consul 服务发现、Redis 缓存、RabbitMQ 消息队列、gRPC、Elasticsearch、Milvus 向量数据库、SQLSugar ORM、JWT 认证、YARP 反向代理、OpenTelemetry 可观测性、Serilog 日志框架、ClickHouse 列式数据库等。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 42 7/16/2026
2.0.7 99 7/10/2026
2.0.5 99 7/8/2026
2.0.3 107 6/30/2026
2.0.0 111 6/29/2026
1.7.3 104 6/29/2026
1.5.0 132 6/16/2026
1.4.0 109 6/15/2026
1.2.0 110 5/29/2026
1.1.1 106 5/25/2026
1.1.0 113 5/22/2026
1.0.9 116 5/20/2026
1.0.8 104 5/20/2026
1.0.7 101 5/20/2026
1.0.6 134 5/19/2026
1.0.5 152 5/13/2026
1.0.4 114 5/13/2026
1.0.3 119 5/13/2026
1.0.2 110 5/13/2026
1.0.1 112 5/13/2026
Loading failed

Initial release of Healnet.Core