using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
namespace APT.Infrastructure.Core
{
public interface IUnitOfWork : IDependInject
{
#region methods
string ConnectionString { get; }
///
/// 对数据库执行给定的 DDL/DML 命令。
///
/// 命令字符串
/// 参数
/// 受影响的行数
int ExecuteSqlCommand(string sql, params object[] parameters);
///
/// 对数据库执行给定的 DDL/DML 命令。
///
/// 事务行为
/// 命令字符串
/// 参数
/// 受影响的行数
int ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, string sql, params object[] parameters);
///
/// 对数据库执行给定的 DDL/DML 命令返回reader。
///
/// 命令字符串
/// reader委托
void ExecuteReader(string sql, ReaderColumn[] readerColumns, Action readerAction);
///
/// 对数据库执行给定的 DDL/DML 命令返回reader。
///
/// 命令字符串
/// 参数
/// reader委托
void ExecuteReader(string sql, ReaderColumn[] readerColumns, DbParameter[] parameters, Action readerAction);
///
/// 对数据库执行给定的 DDL/DML 命令返回reader。
///
/// 命令类型
/// 命令字符串
/// 参数
/// reader委托
void ExecuteReader(CommandType commandType, string sql, ReaderColumn[] readerColumns, DbParameter[] parameters, Action readerAction);
///
/// 对数据库执行给定的 DDL/DML 命令。
///
/// 命令类型
/// 命令字符串
/// 参数
///
int ExecuteNonQuery(CommandType commandType, string sql, ReaderColumn[] readerColumns, DbParameter[] parameters);
///
/// 创建一个原始 SQL 查询,该查询将返回给定类型的元素。
///
/// 查询所返回对象的类型
/// SQL 查询字符串
/// 要应用于 SQL 查询字符串的参数
///
IEnumerable SqlQuery(Type elementType, string sql, ReaderColumn[] readerColumns, params Object[] parameters);
///
/// 提交当前单元操作的更改。
///
/// 操作影响的行数
int SaveChanges();
///
/// 执行数据sql语句
///
/// 执行数据sql语句
Task ExecuteSqlCommandAsync(TransactionalBehavior transactionalBehavior, string sql, params object[] parameters);
///
/// 异步提交当前单元操作的更改。
///
/// 操作影响的行数
Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
///
/// 开启事务
///
void BeginTransaction();
///
/// 提交事务
///
void CommitTransaction();
///
/// 回滚事务
///
void RollbackTransaction();
T AddEntity(T entity) where T : class;
void AddEntities(IEnumerable entities) where T : class;
public void UpdateEntity(T entity) where T : class;
void UpdateEntities(IEnumerable entities) where T : class;
void UpdateEntities(IEnumerable entities, params string[] updateField) where T : class;
void DeleteEntities(IEnumerable entities) where T : class;
DataBaseType GetDataBaseType();
T GetEntity(Expression> expression, string[] selectField = null, params string[] paths) where T : class;
T GetEntity(Expression> expression, string[] selectField = null, bool isTracking = true, params string[] paths) where T : class;
T GetEntity(Expression> expression, Dictionary orders, string[] selectField,
bool isTracking = true, params string[] paths) where T : class;
int GetCount(Expression> expression) where T : class;
IEnumerable GetEntities(Expression> expression, string[] selectField = null, params string[] paths) where T : class;
IEnumerable GetEntities(Expression> expression, string[] selectField = null, bool isTracking = true, params string[] paths) where T : class;
IEnumerable GetOrderEntities(Expression> expression,
Dictionary orders, string[] selectField = null,
params string[] paths) where T : class;
IEnumerable GetOrderEntities(Expression> expression, Dictionary orders, string[] selectField = null,
bool isTracking = true, params string[] paths) where T : class;
IEnumerable GetOrderEntities(Expression> expression, Dictionary orders,
Action> orderBy, string[] selectField,
bool isTracking = true, params string[] paths) where T : class;
PagedResultDto GetOrderPageEntities(Expression> expression, Dictionary orders, string[] selectField,
int pageSize, int startIndex,
params string[] paths) where T : class;
PagedResultDto GetOrderPageEntities(Expression> expression, Dictionary orders, string[] selectField,
int pageSieze, int startIndex, bool isTracking = true,
params string[] paths) where T : class;
PagedResultDto GetOrderPageEntities(Expression> expression, Dictionary orders,
int pageSieze, int startIndex, Action> orderBy, bool isTracking = true,
params string[] paths) where T : class;
PagedResultDto GetOrderPageEntities(Expression> expression, Dictionary orders, string[] selectField,
int pageSize, int startIndex, Action> orderBy, bool isTracking = true,
params string[] paths) where T : class;
//
Task> GetOrderPageEntitiesSync(Expression> expression, Dictionary orders,
int pageSize, int startIndex,
params string[] paths) where T : class;
Task> GetOrderPageEntitiesSync(Expression> expression, Dictionary orders,
int pageSieze, int startIndex, bool isTracking = true,
params string[] paths) where T : class;
Task> GetOrderPageEntitiesSync(Expression> expression, Dictionary orders,
int pageSieze, int startIndex, Action> orderBy, bool isTracking = true,
params string[] paths) where T : class;
PagedResultDto GetPageEntities(Expression> expression, Dictionary orders, string[] selectField,
int pageSieze, int startIndex, Action> orderBy, bool isTracking = true,
params string[] paths) where T : class;
///
/// 根据表名获取表数据结构
///
///
///
EFModelTable GetModelTable(string tableName);
///
/// 根据表名、字段名称获取字段结构
///
///
///
///
EFModelField GetModelField(string tableName, string fieldName);
///
/// 根据表名,导航名称获取外键信息
///
///
///
///
EFModelForeignKey GetModelForeignKey(string tableName, string navName);
///
/// 获取所有外键信息
///
///
///
List GetModelForeignKey(string tableName);
///
/// 根据表名,ID字段名称获取外键信息
///
///
///
///
EFModelForeignKey GetModelForeignKeyById(string tableName, string idFieldName);
public IEnumerable> GetTreeOrderEntities(Expression> expression, BaseFilter filter,
Expression> orgExpression, out List resultList, bool isTracking = true,
params string[] paths) where T : TreeEntityBase, new();
#endregion
}
}