添加项目文件。
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
namespace JinYuan.DAL.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询条件枚举
|
||||
/// </summary>
|
||||
public enum QueryOperator
|
||||
{
|
||||
/// <summary>
|
||||
/// 相等
|
||||
/// </summary>
|
||||
Equal,
|
||||
/// <summary>
|
||||
/// 匹配
|
||||
/// </summary>
|
||||
Like,
|
||||
/// <summary>
|
||||
/// 大于
|
||||
/// </summary>
|
||||
GreaterThan,
|
||||
/// <summary>
|
||||
/// 大于或等于
|
||||
/// </summary>
|
||||
GreaterThanOrEqual,
|
||||
/// <summary>
|
||||
/// 小于
|
||||
/// </summary>
|
||||
LessThan,
|
||||
/// <summary>
|
||||
/// 小于或等于
|
||||
/// </summary>
|
||||
LessThanOrEqual,
|
||||
/// <summary>
|
||||
/// 等于集合
|
||||
/// </summary>
|
||||
In,
|
||||
/// <summary>
|
||||
/// 不等于集合
|
||||
/// </summary>
|
||||
NotIn,
|
||||
/// <summary>
|
||||
/// 左边匹配
|
||||
/// </summary>
|
||||
LikeLeft,
|
||||
/// <summary>
|
||||
/// 右边匹配
|
||||
/// </summary>
|
||||
LikeRight,
|
||||
/// <summary>
|
||||
/// 不相等
|
||||
/// </summary>
|
||||
NoEqual,
|
||||
/// <summary>
|
||||
/// 为空或空
|
||||
/// </summary>
|
||||
IsNullOrEmpty,
|
||||
/// <summary>
|
||||
/// 不为空
|
||||
/// </summary>
|
||||
IsNot,
|
||||
/// <summary>
|
||||
/// 不匹配
|
||||
/// </summary>
|
||||
NoLike,
|
||||
/// <summary>
|
||||
/// 时间段 值用 "|" 隔开
|
||||
/// </summary>
|
||||
DateRange
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询条件运算符
|
||||
/// </summary>
|
||||
public enum QueryCharacter
|
||||
{
|
||||
/// <summary>
|
||||
/// 且
|
||||
/// </summary>
|
||||
And,
|
||||
/// <summary>
|
||||
/// 或
|
||||
/// </summary>
|
||||
Or,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序枚举
|
||||
/// </summary>
|
||||
public enum OrderSequence
|
||||
{
|
||||
/// <summary>
|
||||
/// 正序
|
||||
/// </summary>
|
||||
Asc,
|
||||
/// <summary>
|
||||
/// 倒序
|
||||
/// </summary>
|
||||
Desc
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,626 @@
|
||||
using JinYuan.DAL.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL
|
||||
{
|
||||
public interface ISugarHelper : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 直接暴露 SqlSugar 原生客户端
|
||||
/// </summary>
|
||||
//ISqlSugarClient DbClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始化数据库连接
|
||||
/// </summary>
|
||||
/// <param name="connectionStr"></param>
|
||||
void SetConnectionStr(string connectionStr, SqlSugar.DbType dbType);
|
||||
|
||||
#region 数据库管理
|
||||
/// <summary>
|
||||
/// 添加列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列信息</param>
|
||||
/// <returns></returns>
|
||||
bool AddColumn(string tableName, DbColumnInfo column);
|
||||
/// <summary>
|
||||
/// 添加主键
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="columnName">列名</param>
|
||||
/// <returns></returns>
|
||||
bool AddPrimaryKey(string tableName, string columnName);
|
||||
/// <summary>
|
||||
/// 备份数据库
|
||||
/// </summary>
|
||||
/// <param name="databaseName">数据库名</param>
|
||||
/// <param name="fullFileName">文件名</param>
|
||||
/// <returns></returns>
|
||||
bool BackupDataBase(string databaseName, string fullFileName);
|
||||
/// <summary>
|
||||
/// 备份表
|
||||
/// </summary>
|
||||
/// <param name="oldTableName">旧表名</param>
|
||||
/// <param name="newTableName">行表名</param>
|
||||
/// <param name="maxBackupDataRows">行数</param>
|
||||
/// <returns></returns>
|
||||
bool BackupTable(string oldTableName, string newTableName, int maxBackupDataRows = int.MaxValue);
|
||||
/// <summary>
|
||||
/// 创建表
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="columns">列集合</param>
|
||||
/// <param name="isCreatePrimaryKey">是否创建主键</param>
|
||||
/// <returns></returns>
|
||||
bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true);
|
||||
/// <summary>
|
||||
/// 删除列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="columnName">列名</param>
|
||||
/// <returns></returns>
|
||||
bool DropColumn(string tableName, string columnName);
|
||||
/// <summary>
|
||||
/// 删除约束
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="constraintName">约束名</param>
|
||||
/// <returns></returns>
|
||||
bool DropConstraint(string tableName, string constraintName);
|
||||
/// <summary>
|
||||
/// 删除表
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
bool DropTable(string tableName);
|
||||
/// <summary>
|
||||
/// 获取列信息
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true);
|
||||
/// <summary>
|
||||
/// 获取自增列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <returns></returns>
|
||||
List<string> GetIsIdentities(string tableName);
|
||||
/// <summary>
|
||||
/// 获取主键
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <returns></returns>
|
||||
List<string> GetPrimaries(string tableName);
|
||||
/// <summary>
|
||||
/// 获取表集合
|
||||
/// </summary>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
List<DbTableInfo> GetTableInfoList(bool isCache = true);
|
||||
/// <summary>
|
||||
/// 获取视图集合
|
||||
/// </summary>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
List<DbTableInfo> GetViewInfoList(bool isCache = true);
|
||||
/// <summary>
|
||||
/// 检测列是否存在
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列名</param>
|
||||
/// <returns></returns>
|
||||
bool IsAnyColumn(string tableName, string column);
|
||||
/// <summary>
|
||||
/// 检测约束
|
||||
/// </summary>
|
||||
/// <param name="constraintName">约束名称</param>
|
||||
/// <returns></returns>
|
||||
bool IsAnyConstraint(string constraintName);
|
||||
/// <summary>
|
||||
/// 检测是否有任何系统表权限
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsAnySystemTablePermissions();
|
||||
/// <summary>
|
||||
/// 检测表是否存在
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
bool IsAnyTable(string tableName, bool isCache = true);
|
||||
/// <summary>
|
||||
/// 检测列是否自增列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列名</param>
|
||||
/// <returns></returns>
|
||||
bool IsIdentity(string tableName, string column);
|
||||
/// <summary>
|
||||
/// 检测列是否主键
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列名</param>
|
||||
/// <returns></returns>
|
||||
bool IsPrimaryKey(string tableName, string column);
|
||||
/// <summary>
|
||||
/// 重置列名
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="oldColumnName">旧列名</param>
|
||||
/// <param name="newColumnName">新列名</param>
|
||||
/// <returns></returns>
|
||||
bool RenameColumn(string tableName, string oldColumnName, string newColumnName);
|
||||
/// <summary>
|
||||
/// 重置表数据
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <returns></returns>
|
||||
bool TruncateTable(string tableName);
|
||||
/// <summary>
|
||||
/// 修改列信息
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列信息</param>
|
||||
/// <returns></returns>
|
||||
bool UpdateColumn(string tableName, DbColumnInfo column);
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据库时间
|
||||
/// </summary>
|
||||
/// <returns>返回值</returns>
|
||||
DateTime GetDataBaseTime();
|
||||
#endregion
|
||||
|
||||
#region 查询
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
List<T> QueryAll<T>() where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询-返回自定义数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <typeparam name="TResult">返回值类型</typeparam>
|
||||
/// <param name="expression">返回值表达式</param>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns>值</returns>
|
||||
TResult QuerySelect<T, TResult>(Expression<Func<T, TResult>> expression, Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 查询-返回自定义数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <typeparam name="TResult">返回值类型</typeparam>
|
||||
/// <param name="expression">返回值表达式</param>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns>值</returns>
|
||||
List<TResult> QuerySelectList<T, TResult>(Expression<Func<T, TResult>> expression, Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询单条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns></returns>
|
||||
T Query<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件异步查询单条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> QueryAsync<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询排序数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
T Query<T>(Expression<Func<T, bool>> whereLambda = null, Expression<Func<T, object>> whereLambda2 = null, OrderByType byType = OrderByType.Desc) where T : class, new();
|
||||
/// <summary>
|
||||
/// 根据条件查询集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="whereLambda">过滤条件</param>
|
||||
/// <returns>实体</returns>
|
||||
List<T> QueryWhereList<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
Task<List<T>> QueryWhereListAsync<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 查询排序数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
List<T> QueryList<T>(QueryDescriptor query = null) where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询前N条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sort">排序列名</param>
|
||||
/// <param name="Take">前N条数据</param>
|
||||
/// <param name="whereLambda">条件</param>
|
||||
/// <param name="byType">升序/降序</param>
|
||||
/// <returns></returns>
|
||||
List<T> QueryList<T>(string sort, int Take, Expression<Func<T, bool>> whereLambda = null, OrderByType byType = OrderByType.Desc) where T : class, new();
|
||||
/// <summary>
|
||||
/// 异步查询前N条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sort"></param>
|
||||
/// <param name="Take"></param>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="byType"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> QueryListAsync<T>(string sort, int Take, Expression<Func<T, bool>> whereLambda = null, OrderByType byType = OrderByType.Desc) where T : class, new();
|
||||
/// <summary>
|
||||
/// 根据字段查询排列
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="sort"></param>
|
||||
/// <param name="byType"></param>
|
||||
/// <returns></returns>
|
||||
List<T> QueryList<T>(string sort, Expression<Func<T, bool>> whereLambda = null, OrderByType byType = OrderByType.Asc) where T : class, new ();
|
||||
/// <summary>
|
||||
/// 异步根据字段查询排列
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sort"></param>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="byType"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> QueryListAsync<T>(string sort, Expression<Func<T, bool>> whereLambda = null, OrderByType byType = OrderByType.Asc) where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="sql">sql</param>
|
||||
/// <returns>实体</returns>
|
||||
List<T> QuerySqlList<T>(string sql) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 异步查询集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> QuerySqlListAsync<T>(string sql) where T : class, new();
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="query">过滤条件</param>
|
||||
/// <param name="totalCount">总行数</param>
|
||||
/// <returns>实体</returns>
|
||||
List<T> QueryPageList<T>(QueryDescriptor query, out int totalCount) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 通过多值查询数据集
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="inFieldName">字段名</param>
|
||||
/// <param name="inValues">数据集合</param>
|
||||
/// <returns></returns>
|
||||
List<T> In<T>(string inFieldName, List<dynamic> inValues) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 通过多值(主键)查询数据集
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="values">主键数据集合</param>
|
||||
/// <returns></returns>
|
||||
List<T> In<T>(List<dynamic> values) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 条件查询DataTable
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns>实体</returns>
|
||||
DataTable QueryDataTable<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 查询DataTable
|
||||
/// </summary>
|
||||
/// <param name="sql">sql</param>
|
||||
/// <returns>实体</returns>
|
||||
DataTable QueryDataTable(string sql);
|
||||
/// <summary>
|
||||
/// 查询单个值
|
||||
/// </summary>
|
||||
/// <param name="sql">sql</param>
|
||||
/// <returns>单个值</returns>
|
||||
object QuerySqlScalar(string sql);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="query">过滤条件</param>
|
||||
/// <param name="totalCount">总行数</param>
|
||||
/// <returns>DataTable</returns>
|
||||
DataTable QueryDataTablePageList<T>(QueryDescriptor query, out int totalCount) where T : class, new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Add<T>(T entity) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys">泛型集合</param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Add<T>(List<T> entitys) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="keyValues">字典集合(Key:列名 Value:值)</param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Add<T>(Dictionary<string, object> keyValues) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>返回实体</returns>
|
||||
T AddReturnEntity<T>(T entity) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>返回自增列</returns>
|
||||
int AddReturnIdentity<T>(T entity) where T : class, new();
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>返回bool</returns>
|
||||
bool AddReturnBool<T>(T entity) where T : class, new();
|
||||
/// <summary>
|
||||
/// 异步新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddReturnBoolAsync<T>(T entity) where T : class, new();
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys">泛型集合</param>
|
||||
/// <returns>返回bool</returns>
|
||||
bool AddReturnBool<T>(List<T> entitys) where T : class, new();
|
||||
/// <summary>
|
||||
/// 异步增加
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="entitys"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddReturnBoolAsync<T>(List<T> entitys) where T : class, new();
|
||||
#endregion
|
||||
|
||||
#region 修改
|
||||
/// <summary>
|
||||
/// 修改(主键是更新条件)
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(T entity, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改(主键是更新条件)
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys"> 实体对象集合(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(List<T> entitys, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(T entity, Expression<Func<T, bool>> where, List<string> lstIgnoreColumns = null,
|
||||
bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="update"> 实体对象 </param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(Expression<Func<T, object>> update, Expression<Func<T, bool>> where = null, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 修改+1
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="update"> 实体对象 </param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(Expression<Func<T, bool>> update, Expression<Func<T, bool>> where = null, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 异步修改+1
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="update"></param>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="isLock"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdateAsync<T>(Expression<Func<T, bool>> update, Expression<Func<T, bool>> where = null, bool isLock = true) where T : class, new();
|
||||
|
||||
Task<int> UpdateAsync<T>(List<T> entitys, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改单条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="isLock"></param>
|
||||
/// <returns></returns>
|
||||
int UpdateSingle<T>(T entity, Expression<Func<T, object>> where = null, Expression<Func<T, bool>> where2 = null, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 异步修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="where2"></param>
|
||||
/// <param name="isLock"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdateSingleAsync<T>(T entity, Expression<Func<T, object>> where = null, Expression<Func<T, bool>> where2 = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="keyValues">字典集合(Key:列名 Value:值)</param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(Dictionary<string, T> keyValues, Expression<Func<T, bool>> where = null, bool isLock = true)
|
||||
where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 批量修改需要更新的列
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys"> 实体对象(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="updateColumns">更新指定列</param>
|
||||
/// <param name="wherecolumns">条件(为空则以主键更新,反之需要把wherecolumns中的列加到UpdateColumns中)</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int UpdateColumns<T>(List<T> entitys, Expression<Func<T, object>> updateColumns,
|
||||
Expression<Func<T, object>> wherecolumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改 通过RowVer及主键Code 更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int UpdateRowVer<T>(T entity, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改 通过RowVer及主键Code 更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="update"> 实体对象 </param>
|
||||
/// <param name="where"> 更新条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int UpdateRowVer<T>(Expression<Func<T, object>> update, Dictionary<string, object> where, bool isLock = true) where T : class, new();
|
||||
#endregion
|
||||
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <summary>
|
||||
/// 删除 通过主键数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="primaryKeyValues">主键值</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int DeleteByPrimary<T>(List<object> primaryKeyValues, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体类删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Delete<T>(T entity, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化表
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void Delete<T>() where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体类集合删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 (必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Delete<T>(List<T> entity, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Delete<T>(Expression<Func<T, bool>> where, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 异步删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="isLock"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> DeleteAsync<T>(Expression<Func<T, bool>> where, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 通过多值(主键)删除数据集
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="inValues">数据集合</param>
|
||||
/// <returns></returns>
|
||||
int DeleteIn<T>(List<dynamic> inValues) where T : class, new();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{114AA012-29C9-418C-A2D6-3173C5341F51}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.DAL</RootNamespace>
|
||||
<AssemblyName>JinYuan.DAL</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Protobuf, Version=3.26.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Protobuf.3.26.1\lib\net45\Google.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.3.8\lib\net462\K4os.Compression.LZ4.Streams.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=9.1.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.9.1.0\lib\net48\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SqlSugar, Version=5.1.4.174, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SqlSugar.5.1.4.175\lib\SqlSugar.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.OracleClient" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Pipelines, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.7.0.0\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Permissions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Permissions.7.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="ZstdSharp, Version=0.8.0.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ZstdSharp.Port.0.8.0\lib\net462\ZstdSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Enums\Enums.cs" />
|
||||
<Compile Include="ISugarHelper.cs" />
|
||||
<Compile Include="Models\OrderSortEntity.cs" />
|
||||
<Compile Include="Models\QueryCondition.cs" />
|
||||
<Compile Include="Models\QueryDescriptor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SQLSugarHelper.cs" />
|
||||
<Compile Include="SQLSugarService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JinYuan.Helper\JinYuan.Helper.csproj">
|
||||
<Project>{258D0AB7-2B4F-4D8F-A3CD-7A8CB4A85360}</Project>
|
||||
<Name>JinYuan.Helper</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,19 @@
|
||||
using JinYuan.DAL.Enums;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 排序实体
|
||||
/// </summary>
|
||||
public class OrderSortEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
/// </summary>
|
||||
public string Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 排序类型
|
||||
/// </summary>
|
||||
public OrderSequence Order { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using JinYuan.DAL.Enums;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
public class QueryCondition
|
||||
{
|
||||
/// <summary>
|
||||
/// 字段名称
|
||||
/// </summary>
|
||||
public string Key { get; set; }
|
||||
/// <summary>
|
||||
/// 查询操作
|
||||
/// </summary>
|
||||
public QueryOperator Operator { get; set; }
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
/// <summary>
|
||||
/// 运算符
|
||||
/// </summary>
|
||||
public QueryCharacter Character { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询集合
|
||||
/// </summary>
|
||||
public class QueryDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// 行数
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
/// <summary>
|
||||
/// 页码
|
||||
/// </summary>
|
||||
public int PageIndex { get; set; }
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public List<OrderSortEntity> OrderBys { get; set; }
|
||||
/// <summary>
|
||||
/// 条件
|
||||
/// </summary>
|
||||
public List<QueryCondition> Conditions { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.DAL")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.DAL")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("114aa012-29c9-418c-a2d6-3173c5341f51")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
using JinYuan.Helper;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace JinYuan.DAL
|
||||
{
|
||||
public class SQLSugarHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库连接字符串
|
||||
/// </summary>
|
||||
public static string connString = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
public static SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer;
|
||||
|
||||
public static SqlSugarScope SqlSugarClient
|
||||
{
|
||||
get
|
||||
{
|
||||
//如果配置了 SlaveConnectionConfigs那就是主从模式,所有的写入删除更新都走主库,查询走从库,
|
||||
var db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = connString,
|
||||
DbType = dbType, //数据库类型
|
||||
IsAutoCloseConnection = true, //默认false,自动释放和关闭数据库连接,设置为true无需使用using或者close操作
|
||||
InitKeyType = InitKeyType.Attribute //默认SystemTable,该属性是不是主键,是不是标识列等等信息
|
||||
|
||||
});
|
||||
db.Ado.CommandTimeOut = 3000;//设置执行语法超时时间
|
||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
||||
{
|
||||
LogHelper.Instance.WriteLog($"执行时间:{db.Ado.SqlExecutionTime.TotalMilliseconds}毫秒 \r\nSQL如下:{sql} \r\n参数:{GetParams(pars)} ", "SQL执行");
|
||||
};
|
||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||
{
|
||||
if (db.TempItems == null) db.TempItems = new Dictionary<string, object>();
|
||||
};
|
||||
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
||||
{
|
||||
LogHelper.Instance.WriteError($"SQL错误:{exp.Message}\r\nSQL如下:{exp.Sql}", "SQL执行");
|
||||
throw new Exception(exp.Message);
|
||||
};
|
||||
db.Aop.OnDiffLogEvent = (it) => //可以方便拿到 数据库操作前和操作后的数据变化。
|
||||
{
|
||||
var editBeforeData = it.BeforeData; //变化前数据
|
||||
var editAfterData = it.AfterData; //变化后数据
|
||||
var sql = it.Sql; //SQL
|
||||
var parameter = it.Parameters; //参数
|
||||
var data = it.BusinessData; //业务数据
|
||||
var time = it.Time ?? new TimeSpan(); //时间
|
||||
var diffType = it.DiffType; //枚举值 insert 、update 和 delete 用来作业务区分
|
||||
|
||||
//你可以在这里面写日志方法
|
||||
var log = $"时间:{time.TotalMilliseconds}\r\n";
|
||||
log += $"类型:{diffType.ToString()}\r\n";
|
||||
log += $"SQL:{sql}\r\n";
|
||||
log += $"参数:{GetParams(parameter)}\r\n";
|
||||
log += $"业务数据:{JsonHelper.EntityToJson(data)}\r\n";
|
||||
log += $"变化前数据:{JsonHelper.EntityToJson(editBeforeData)}\r\n";
|
||||
log += $"变化后数据:{JsonHelper.EntityToJson(editAfterData)}\r\n";
|
||||
//SqlLogHelper.WriteLog(log, "数据变化前后");
|
||||
};
|
||||
return db;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取参数信息
|
||||
/// </summary>
|
||||
/// <param name="pars"></param>
|
||||
/// <returns></returns>
|
||||
private static string GetParams(SugarParameter[] pars)
|
||||
{
|
||||
return pars.Aggregate("", (current, p) => current + $"{p.ParameterName}:{p.Value}, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.1.0.0" newVersion="9.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.23.4.0" newVersion="3.23.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ZstdSharp" publicKeyToken="8d151af33a4ad5cf" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.7.2.0" newVersion="0.7.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Configuration.ConfigurationManager" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle.Cryptography" version="2.3.1" targetFramework="net48" />
|
||||
<package id="Google.Protobuf" version="3.26.1" targetFramework="net48" />
|
||||
<package id="K4os.Compression.LZ4" version="1.3.8" targetFramework="net48" />
|
||||
<package id="K4os.Compression.LZ4.Streams" version="1.3.8" targetFramework="net48" />
|
||||
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net462" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="9.0.0" targetFramework="net472" />
|
||||
<package id="MySql.Data" version="9.1.0" targetFramework="net48" />
|
||||
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net462" />
|
||||
<package id="SqlSugar" version="5.1.4.175" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
||||
<package id="System.Configuration.ConfigurationManager" version="8.0.0" targetFramework="net472" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net48" />
|
||||
<package id="System.IO.Pipelines" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
|
||||
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Permissions" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
|
||||
<package id="ZstdSharp.Port" version="0.8.0" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user