mh_frame_sps/APT.Infrastructure.Core/EF/IRepository.cs

223 lines
11 KiB
C#
Raw Normal View History

2026-04-07 13:47:52 +08:00
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace APT.Infrastructure.Core
{
public interface IRepository : IDependInject
{
#region properties
/// <summary>
/// 获取 当前单元操作对象
/// </summary>
IUnitOfWork UnitOfWork { get; }
#endregion
#region methods
void AddEntity<T>(T entity, bool isSave = true) where T : MesEntityBase, new();
T AddAndGetEntity<T>(T entity, bool isSave = true) where T : MesEntityBase, new();
void AddEntities<T>(IEnumerable<T> entities, bool isSave = true) where T : MesEntityBase, new();
void DeleteEntity<T>(T entity, bool isSave = true) where T : MesEntityBase, new();
void DeleteEntity<T>(Guid key, bool isSave = true) where T : MesEntityBase, new();
void DeleteEntity<T>(Expression<Func<T, bool>> predicate, bool isSave = true) where T : MesEntityBase, new();
void DeleteEntities<T>(IEnumerable<T> entities, bool isSave = true) where T : MesEntityBase, new();
bool UpdateEntity<T>(T entity, bool isSave = true, params string[] updateField) where T : MesEntityBase, new();
void UpdateEntities<T>(IEnumerable<T> entities, bool isSave = true, params string[] updateField) where T : MesEntityBase, new();
void SaveEntities<T>(IEnumerable<T> entities, bool isSave = true) where T : MesEntityBase, new();
T GetEntity<T>(Guid id, params string[] paths)
where T : MesEntityBase, new();
T GetEntity<T>(Expression<Func<T, bool>> expression, BaseFilter filter, params string[] paths)
where T : MesEntityBase, new();
T GetEntity<T>(Expression<Func<T, bool>> expression, BaseFilter filter, bool isTracking = true, params string[] paths)
where T : MesEntityBase, new();
T GetEntityByRedis<T>(string key, Guid orgid) where T : MesEntityBase, new();
Task<List<T>> GetEntitiesByRedis<T>(BaseFilter filter) where T : MesEntityBase, new();
List<T> GetEntitiesByRedis<T>(Expression<Func<T, bool>> expression, BaseFilter filter) where T : MesEntityBase, new();
Task<List<T>> GetEntitiesTableByRedis<T>(Expression<Func<T, bool>> expression, BaseFilter filter,
params string[] paths) where T : MesEntityBase, new();
Task<List<T>> GetEntitiesByRedis<T>(Expression<Func<T, bool>> expression, BaseFilter filter, string groupValue,
params string[] paths) where T : MesEntityBase, new();
PagedResultDto<T> GetOrderPageByRedis<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
params string[] paths) where T : MesEntityBase, new();
T GetEntityByRedis<T>(Guid key, Guid orgid) where T : MesEntityBase, new();
Task<List<T>> GetEntitiesByGroupRedis<T>(BaseFilter filter, string groupValue) where T : MesEntityBase, new();
IEnumerable<T> GetEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter,
params string[] paths) where T : MesEntityBase, new();
IEnumerable<T> GetEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter,
bool isTracking = true, params string[] paths) where T : MesEntityBase, new();
IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter,
params string[] paths) where T : MesEntityBase, new();
IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter,
bool isTracking = true, params string[] paths) where T : MesEntityBase, new();
IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, Dictionary<string, string> orders,
bool isTracking = true, params string[] paths) where T : MesEntityBase, new();
IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, Dictionary<string, string> orders,
Action<IOrderable<T>> orderBy,
bool isTracking = true, params string[] paths) where T : MesEntityBase, new();
PagedResultDto<T> GetPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
params string[] paths) where T : MesEntityBase, new();
PagedResultDto<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
params string[] paths) where T : MesEntityBase, new();
PagedResultDto<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
int pageSize, int startIndex,
params string[] paths) where T : MesEntityBase, new();
PagedResultDto<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
int pageSize, int startIndex, bool isTracking = true,
params string[] paths) where T : MesEntityBase, new();
PagedResultDto<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
Dictionary<string, string> orders,
int pageSize, int startIndex, bool isTracking = true,
params string[] paths) where T : MesEntityBase, new();
IEnumerable<TreeNode<T>> GetTreeOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, bool isTracking = true,
params string[] paths) where T : TreeEntityBase<T>, new();
IEnumerable<T> GetTree<T>(string id, bool containCurrent = true, BaseFilter filter = null,
params string[] paths) where T : TreeEntityBase<T>, new();
PagedResultDto<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
Dictionary<string, string> orders,
int pageSize, int startIndex, Action<IOrderable<T>> orderBy, bool isTracking = true,
params string[] paths) where T : MesEntityBase, new();
//
PagedResultDto<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
string[] selectField, params string[] paths) where T : MesEntityBase, new();
Task<PagedResultDto<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
params string[] paths) where T : MesEntityBase, new();
Task<PagedResultDto<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
int pageSize, int startIndex,
params string[] paths) where T : MesEntityBase, new();
Task<PagedResultDto<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
int pageSize, int startIndex, bool isTracking = true,
params string[] paths) where T : MesEntityBase, new();
Task<PagedResultDto<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
Dictionary<string, string> orders,
int pageSize, int startIndex, bool isTracking = true,
params string[] paths) where T : MesEntityBase, new();
Task<PagedResultDto<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
Dictionary<string, string> orders,
int pageSize, int startIndex, Action<IOrderable<T>> orderBy, bool isTracking = true,
params string[] paths) where T : MesEntityBase, new();
int GetCount<T>(Expression<Func<T, bool>> expression, BaseFilter filter) where T : MesEntityBase, new();
bool IsAny<T>(Expression<Func<T, bool>> expression, BaseFilter filter) where T : MesEntityBase, new();
#endregion
/// <summary>
/// 填充系统参数
/// </summary>
/// <param name="entities"></param>
/// <param name="filter"></param>
/// <param name="includes"></param>
void FillGetEntitySysParam<T>(IEnumerable<T> entities, BaseFilter filter, string[] includes);
T AddAndGetEntity_noneBase<T>(T entity) where T : class;
void AddEntities_noneBase<T>(IEnumerable<T> entities) where T : class;
T GetEntity_noneBase<T>(Expression<Func<T, bool>> expressions) where T : class;
List<T> GetEntities_noneBase<T>(Expression<Func<T, bool>> expressions) where T : class;
void UpdateEntities_noneBase<T>(IEnumerable<T> entities) where T : class;
void DeleteEntity_noneBase<T>(Expression<Func<T, bool>> expression) where T : class;
#region nocomit
void AddEntityNoCommit<T>(T entity) where T : MesEntityBase, new();
void AddEntitiesNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new();
void UpdateEntitiesNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new();
bool UpdateEntityNoCommit<T>(T entity, params string[] updateField) where T : MesEntityBase, new();
void UpdateEntitiesNoCommit<T>(IEnumerable<T> entities, params string[] updateField) where T : MesEntityBase, new();
void DeleteEntityNoCommit<T>(Expression<Func<T, bool>> expression) where T : MesEntityBase, new();
void DeleteEntityNoCommit<T>(T entity) where T : MesEntityBase, new();
void DeleteEntityNoCommit<T>(Guid id) where T : MesEntityBase, new();
void DeleteEntitiesNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new();
void SaveEntitiesNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new();
T AddAndGetEntityNoCommit<T>(T entity) where T : MesEntityBase, new();
void AddEntityByConn<T>(T entity, string conn) where T : MesEntityBase, new();
void UpdateEntitiesByConn<T>(IEnumerable<T> entities, string conn) where T : MesEntityBase, new();
void UpdateEntityByConn<T>(T entity, string conn, params string[] updateField) where T : MesEntityBase, new();
void DeleteEntityByConn<T>(Expression<Func<T, bool>> expression, string conn) where T : MesEntityBase, new();
void DeleteEntityByConn<T>(T entity, string conn) where T : MesEntityBase, new();
void DeleteEntityByConn<T>(Guid id, string conn) where T : MesEntityBase, new();
void DeleteEntitiesByConn<T>(IEnumerable<T> entities, string conn) where T : MesEntityBase, new();
void AddEntitiesByConn<T>(IEnumerable<T> entities, string conn) where T : MesEntityBase, new();
void UpdateEntitiesByConn<T>(IEnumerable<T> entities, string conn, params string[] updateField) where T : MesEntityBase, new();
//Tenant
void AddEntityByTenant<T>(T entity, string Tenant) where T : MesEntityBase, new();
void UpdateEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant) where T : MesEntityBase, new();
void UpdateEntityByTenant<T>(T entity, string Tenant, params string[] updateField) where T : MesEntityBase, new();
void DeleteEntityByTenant<T>(Expression<Func<T, bool>> expression, string Tenant) where T : MesEntityBase, new();
void DeleteEntityByTenant<T>(T entity, string Tenant) where T : MesEntityBase, new();
void DeleteEntityByTenant<T>(Guid id, string Tenant) where T : MesEntityBase, new();
void DeleteEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant) where T : MesEntityBase, new();
void AddEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant) where T : MesEntityBase, new();
void UpdateEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant, params string[] updateField) where T : MesEntityBase, new();
#endregion
}
}