LightPoint.Foundation.Kernel.DtoServices
1.3.5.8
dotnet add package LightPoint.Foundation.Kernel.DtoServices --version 1.3.5.8
NuGet\Install-Package LightPoint.Foundation.Kernel.DtoServices -Version 1.3.5.8
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="LightPoint.Foundation.Kernel.DtoServices" Version="1.3.5.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LightPoint.Foundation.Kernel.DtoServices" Version="1.3.5.8" />
<PackageReference Include="LightPoint.Foundation.Kernel.DtoServices" />
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 LightPoint.Foundation.Kernel.DtoServices --version 1.3.5.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LightPoint.Foundation.Kernel.DtoServices, 1.3.5.8"
#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 LightPoint.Foundation.Kernel.DtoServices@1.3.5.8
#: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=LightPoint.Foundation.Kernel.DtoServices&version=1.3.5.8
#tool nuget:?package=LightPoint.Foundation.Kernel.DtoServices&version=1.3.5.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
简要说明
LigthPoint 应用技术架构中,定制的 Dto 相关操作的服务接口,及其实现。
接口方法清单如下:
/// <summary>
/// Dto 服务接口,用于定义和约束数据传输对象的相关操作方法,需要结合早期的成果。
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TDto"></typeparam>
public interface ILpDtoService<TEntity,TDto>
where TEntity : class, ILpEntityBase, new()
where TDto : class, ILpDtoBase, new()
{
#region 1. 查询单个 DTO 对象
/// <summary>
/// 根据 Id 获取单个领域泛型对象的仓储数据,并转换成数据传输对象
/// </summary>
/// <param name="id">待查询领域泛型对象的 Id</param>
/// <returns></returns>
Task<TDto?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);
/// <summary>
/// 根据类型名称和Id查询对象
/// </summary>
/// <param name="typeName"></param>
/// <param name="id"></param>
/// <returns></returns>
Task<object?> GetByTypeNameAndId(string typeName, Guid id);
/// <summary>
/// 根据查询条件,获取单个领域泛型对象的领域对象仓储数据,并转换成数据传输对象
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
Task<TDto?> FirstOrDefaultAsync(Expression<Func<TEntity, bool>>? predicate = null);
/// <summary>
/// 根据数据归约 <see cref="ILpSpecification{T}" /> 查询,返回第一个或者默认的对象,并转换成数据传输对象
/// </summary>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<TDto?> FirstOrDefaultAsync(ILpSpecification<TEntity> specification, CancellationToken cancellationToken = default);
/// <summary>
/// 根据数据归约 <see cref="ILpSpecification{T, TResult}" /> 查询,按结果类型规约返回 TResult 第一个或者默认的对象,并转换成数据传输对象
/// </summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<DtoResult> FirstOrDefaultAsync<DtoResult, EntityResult>(ILpSpecification<TEntity, EntityResult> specification, CancellationToken cancellationToken = default)
where EntityResult : class, ILpEntityBase, new()
where DtoResult : class, ILpDtoBase, new();
/// <summary>
/// 根据查询条件,返回一个或者默认的对象,并转换成数据传输对象
/// </summary>
/// <param name="predicate"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<TDto?> SingleOrDefaultAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
/// <summary>
/// 根据数据归约 <see cref="ILpSingleResultSpecification{T}" /> 查询,返回一个或者默认的对象
/// </summary>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<TDto?> SingleOrDefaultAsync(ILpSingleResultSpecification<TEntity> specification, CancellationToken cancellationToken = default);
/// <summary>
/// 根据数据归约 <see cref="ISingleResultSpecification{T, TResult}" /> 查询,按结果类型规约返回 TResult 一个或者默认的对象
/// </summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<DtoResult?> SingleOrDefaultAsync<DtoResult, EntityResult>(ISingleResultSpecification<TEntity, EntityResult> specification, CancellationToken cancellationToken = default)
where EntityResult : class, ILpEntityBase, new()
where DtoResult : class, ILpDtoBase, new();
#endregion
#region 2. 查询对象的数量
/// <summary>
/// 获取当前仓储(数据库)里面的领域泛型对象的总数
/// </summary>
/// <returns></returns>
Task<int> CountAsync(CancellationToken cancellationToken = default);
/// <summary>
/// 根据根据数据归约 <see cref="ILpSpecification{T}" /> ,获取当前仓储(数据库)里面满足查询条件的领域泛型对象总数
/// </summary>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<int> CountAsync(ILpSpecification<TEntity> specification, CancellationToken cancellationToken = default);
/// <summary>
/// 根据据查询条件,获取当前仓储(数据库)里面满足查询条件的领域泛型对象总数
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
#endregion
#region 3. 检查对象是否存在
/// <summary>
/// 检查是否存在满足数据归约 <see cref="ILpSpecification{T}" /> 的对象
/// </summary>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<bool> AnyAsync(ILpSpecification<TEntity> specification, CancellationToken cancellationToken = default);
/// <summary>
/// 是否存在任意的对象
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<bool> AnyAsync(CancellationToken cancellationToken = default);
/// <summary>
/// 根据 Id 查找对应的领域泛型对象领域对象是否存在
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<bool> AnyAsync(Guid id, CancellationToken cancellationToken = default);
/// <summary>
/// 根据查询表达式条件查找对应的领域泛型对象领域对象是否存在
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
#endregion
#region 4. 针对指定的属性进行求和或者求均值
/// <summary>
/// 根据查询表达式条件查找对应的领域泛型对象领域对象数据,并计算数据某个属性的总和
/// </summary>
/// <typeparam name="TEntityProperty">要计算的属性类型</typeparam>
/// <param name="predicate">模型对象的查询条件表达式</param>
/// <param name="selector">要计算的属性选择表达式</param>
/// <returns></returns>
Task<TEntityProperty> SumAsync<TEntityProperty>(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, TEntityProperty>> selector, CancellationToken cancellationToken = default) where TEntityProperty : unmanaged;
/// <summary>
/// 根据查询表达式条件查找对应的领域泛型对象领域对象数据
/// 并计算数据某个属性的平均值
/// </summary>
/// <typeparam name="TModelDataProp">要计算的属性类型</typeparam>
/// <param name="predicate">模型对象的查询条件表达式</param>
/// <param name="selector">要计算的属性选择表达式</param>
/// <returns></returns>
Task<TEntityProperty> AverageAsync<TEntityProperty>(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, TEntityProperty>> selector, CancellationToken cancellationToken = default) where TEntityProperty : unmanaged;
#endregion
#region 5. 查询对象集合-不分页
/// <summary>
/// 一次性查询并返回会所有的对象的 List 集合
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<TDto>> ListAsync(CancellationToken cancellationToken = default);
/// <summary>
/// 根据查询条件返回所有的对象的 List 集合
/// </summary>
/// <param name="predicate"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<TDto>> ListAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
/// <summary>
/// 根据数据归约 <see cref="ILpSpecification{T}" /> 查询并返回所有的对象的 List 集合
/// </summary>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<TDto>> ListAsync(ILpSpecification<TEntity> specification, CancellationToken cancellationToken = default);
/// 根据数据归约 <see cref="ILpSpecification{T, TResult}" /> 查询并返回指定的 TResult 所有的对象的 List 集合
/// </summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<DtoResult>> ListAsync<DtoResult, EntityResult>(ILpSpecification<TEntity, EntityResult> specification, CancellationToken cancellationToken = default)
where EntityResult : class, ILpEntityBase, new()
where DtoResult : class, ILpDtoBase, new();
#endregion
#region 6. 查询对象集合-分页
/// <summary>
/// 分页查询所有的对象,按照指定的页码和每页大小返回分页的数据结果,按默认的排序规则(SortCode 升序)排序
/// </summary>
/// <param name="pageNumber"></param>
/// <param name="pageSize"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpPagedResult<TDto>> PaginateAsync(long pageNumber, long pageSize, CancellationToken cancellationToken = default);
/// <summary>
/// 根据查询条件分页查询所有的对象,按照指定的页码和每页大小返回分页的数据结果,按默认的排序规则(SortCode 升序)排序
/// </summary>
/// <param name="pageNumber"></param>
/// <param name="pageSize"></param>
/// <param name="predicate"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpPagedResult<TDto>> PaginateAsync(long pageNumber, long pageSize, Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
/// <summary>
/// 根据数据归约 <see cref="ILpSpecification{T}" /> 分页查询所有的对象,按照指定的页码和每页大小返回分页的数据结果,排序规则由 <see cref="ILpSpecification{T}" /> 指定
/// </summary>
/// <param name="pageNumber"></param>
/// <param name="pageSize"></param>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpPagedResult<TDto>> PaginateAsync(long pageNumber, long pageSize, ILpSpecification<TEntity> specification, CancellationToken cancellationToken = default);
#endregion
#region 7. 添加数据的方法
/// <summary>
/// 添加一个数据,并将添加后的数据返回
/// </summary>
/// <param name="entity"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpResult<TDto>> AddAsync(TDto dto, CancellationToken cancellationToken = default);
/// <summary>
/// 批量添加数据,返回数据将加载在 Values 中
/// </summary>
/// <param name="entities"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpResult<TDto>> AddRangeAsync(IEnumerable<TDto> dtoCollection, CancellationToken cancellationToken = default);
#endregion
#region 8. 更新数据的方法
/// <summary>
/// 常规的更新方法,根据 Id 和传入的 Dto 更新数据
/// </summary>
/// <param name="id"></param>
/// <param name="dto"></param>
/// <returns></returns>
Task<LpResult<TDto>> UpdateAsync(Guid id, TDto dto, CancellationToken cancellationToken = default);
/// <summary>
/// 针对一些简单的更新操作,可以直接传入查询条件和要更新的属性和值,直接在仓储中进行更新,而不需要进行 Dto 和 Entity 的转换
/// </summary>
/// <param name="predicateExpression"></param>
/// <param name="propertyAndValues"></param>
/// <returns></returns>
Task<LpResult<TDto>> UpdateAsync(Expression<Func<TEntity, bool>> predicateExpression, List<KeyValuePair<string, object>> propertyAndValues, CancellationToken cancellationToken = default);
/// <summary>
/// 批量更新数据
/// </summary>
/// <param name="entities"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpResult<TDto>> UpdateRangeAsync(IEnumerable<TDto> dtos, CancellationToken cancellationToken = default);
#endregion
#region 9. 删除数据的方法
/// <summary>
/// 根据 Id 删除对应的领域泛型对象的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<LpResult<TDto>> DeleteAsync(Guid id, CancellationToken cancellationToken = default);
/// <summary>
/// 根据传入的实体删除数据
/// </summary>
/// <param name="entity"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpResult<TDto>> DeleteAsync(TDto dto, CancellationToken cancellationToken = default);
/// <summary>
/// 批量删除指定的数据
/// </summary>
/// <param name="entities"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpResult<TDto>> DeleteRangeAsync(IEnumerable<TDto> dtos, CancellationToken cancellationToken = default);
/// <summary>
/// 根据查询条件删除对应的领域泛型对象的数据
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
Task<LpResult<TDto>> DeleteRangeAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
/// <summary>
/// 根据数据归约 <see cref="ILpSpecification{T}" /> 批量删除数据
/// </summary>
/// <param name="specification"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<LpResult<TDto>> DeleteRangeAsync(ILpSpecification<TEntity> specification, CancellationToken cancellationToken = default);
#endregion
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net9.0
- LightPoint.Foundation.Base (>= 1.3.5.7)
- LightPoint.Foundation.Kernel (>= 1.3.5.8)
- LightPoint.Foundation.Kernel.Mapper (>= 1.3.5.8)
- LightPoint.Foundation.Result (>= 1.3.5.8)
- LightPoint.Foundation.Result.AspNetCore (>= 1.3.5.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.3.5.8 | 121 | 12/17/2024 |
1.3.5.7 | 126 | 11/20/2024 |
1.3.5.6 | 118 | 11/13/2024 |
1.3.5.5 | 130 | 9/25/2024 |
1.3.5.3 | 127 | 9/1/2024 |
1.3.5.2 | 121 | 8/29/2024 |
1.3.5.1 | 117 | 8/29/2024 |
1.3.4.5 | 142 | 8/19/2024 |
1.3.4.4 | 136 | 8/19/2024 |
1.3.4.3 | 134 | 8/19/2024 |
1.3.4.2 | 140 | 8/19/2024 |
1.3.4.1 | 102 | 8/4/2024 |
1.3.4 | 125 | 8/1/2024 |
1.3.1 | 103 | 7/25/2024 |
1.3.0 | 91 | 7/25/2024 |