| | |
| | | private static string _connectionString = connectObject.Connection; |
| | | private static DbType _dbType = (DbType)connectObject.DbType; |
| | | public static string ConnId = connectObject.ConnId; |
| | | private SqlSugarClient _db; |
| | | private SqlSugarScope _db; |
| | | |
| | | /// <summary> |
| | | /// 连接字符串 |
| | |
| | | /// <summary> |
| | | /// 数据连接对象 |
| | | /// </summary> |
| | | public SqlSugarClient Db |
| | | public SqlSugarScope Db |
| | | { |
| | | get { return _db; } |
| | | private set { _db = value; } |
| | |
| | | if (string.IsNullOrEmpty(_connectionString)) |
| | | throw new ArgumentNullException("数据库连接字符串为空"); |
| | | |
| | | _db = sqlSugarClient as SqlSugarClient; |
| | | _db = sqlSugarClient as SqlSugarScope; |
| | | //_db.Aop.DataExecuting = SqlSugarAop.DataExecuting; |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="config">config</param> |
| | | /// <returns>返回值</returns> |
| | | public static SqlSugarClient GetCustomDB(ConnectionConfig config) |
| | | public static SqlSugarScope GetCustomDB(ConnectionConfig config) |
| | | { |
| | | return new SqlSugarClient(config); |
| | | return new SqlSugarScope(config); |
| | | } |
| | | /// <summary> |
| | | /// 功能描述:获取一个自定义的数据库处理对象 |
| | | /// </summary> |
| | | /// <param name="sugarClient">sugarClient</param> |
| | | /// <returns>返回值</returns> |
| | | public static SimpleClient<T> GetCustomEntityDB<T>(SqlSugarClient sugarClient) where T : class, new() |
| | | { |
| | | return new SimpleClient<T>(sugarClient); |
| | | } |
| | | //public static SqlSugarScope<T> GetCustomEntityDB<T>(SqlSugarScope sugarClient) where T : class, new() |
| | | //{ |
| | | // return new SqlSugarScope<T>(sugarClient); |
| | | //} |
| | | /// <summary> |
| | | /// 功能描述:获取一个自定义的数据库处理对象 |
| | | /// </summary> |
| | | /// <param name="config">config</param> |
| | | /// <returns>返回值</returns> |
| | | public static SimpleClient<T> GetCustomEntityDB<T>(ConnectionConfig config) where T : class, new() |
| | | { |
| | | SqlSugarClient sugarClient = GetCustomDB(config); |
| | | return GetCustomEntityDB<T>(sugarClient); |
| | | } |
| | | //public static SimpleClient<T> GetCustomEntityDB<T>(ConnectionConfig config) where T : class, new() |
| | | //{ |
| | | // SqlSugarScope sugarClient = GetCustomDB(config); |
| | | // return GetCustomEntityDB<T>(sugarClient); |
| | | //} |
| | | #endregion |
| | | } |
| | | } |