/// <summary> /// 构造 /// </summary> public BaseRepository() { DbContext.Init(DBConfigHelper.ConnectionString, (DbType)DBConfigHelper.DbType); _context = DbContext.GetDbContext(); _db = _context.Db; _entityDb = _context.GetEntityDB <TEntity>(_db); }
/// <summary> /// 构造函数 /// </summary> public DbContext() { if (string.IsNullOrEmpty(_connectionString)) { throw new ArgumentNullException("数据库连接字符串为空."); } _db = new SqlDbLiteClient(new ConnectionConfig() { ConnectionString = _connectionString, DbType = _dbType, IsAutoCloseConnection = true, IsShardSameThread = false, InitKeyType = InitKeyType.Attribute,//mark ConfigureExternalServices = new ConfigureExternalServices() { //DataInfoCacheService = new HttpRuntimeCache() }, MoreSettings = new ConnMoreSettings() { //IsWithNoLockQuery = true, IsAutoRemoveDataCache = true } }); }
/// <summary> /// 获取一个自定义的数据库处理对象 /// </summary> /// <param name="config">config</param> /// <returns>返回值</returns> public static SimpleClient <T> GetCustomEntityDB <T>(ConnectionConfig config) where T : class, new() { SqlDbLiteClient DbLiteClient = GetCustomDB(config); return(GetCustomEntityDB <T>(DbLiteClient)); }
/// <summary> /// 获取数据库处理对象 /// </summary> /// <param name="db">db</param> /// <returns>返回值</returns> public SimpleClient <T> GetEntityDB <T>(SqlDbLiteClient db) where T : class, new() { return(new SimpleClient <T>(db)); }
/// <summary> /// 获取一个自定义的数据库处理对象 /// </summary> /// <param name="DbLiteClient">DbLiteClient</param> /// <returns>返回值</returns> public static SimpleClient <T> GetCustomEntityDB <T>(SqlDbLiteClient DbLiteClient) where T : class, new() { return(new SimpleClient <T>(DbLiteClient)); }