public static T CloneWith <T>(this T connectionManager, IDbConnectionString connectionString) where T : class, IConnectionManager { if (connectionManager is null) { throw new ArgumentNullException(nameof(connectionManager)); } if (connectionString is null) { throw new ArgumentNullException(nameof(connectionString)); } var clone = (T)connectionManager.Clone(); clone.ConnectionString = connectionString; return(clone); }
public DbConnectionManager(IDbConnectionString connectionString) : this() { this.ConnectionString = connectionString; }
public SMOConnectionManager(ConnectionString connectionString) { //RuntimePolicyHelper.SetNET20Compatibilty(); ConnectionString = connectionString; SqlConnectionManager = new SqlConnectionManager(connectionString); }
public RepositoryVeiculo(IDbConnectionString dbConnectionString) { _dbConnectionString = dbConnectionString; DefaultTypeMap.MatchNamesWithUnderscores = true; }
public SMOConnectionManager(ConnectionString connectionString) { ConnectionString = connectionString; SqlConnectionManager = new SqlConnectionManager(connectionString); }
/// <summary> /// 获取数据驱动接口实例 /// </summary> /// <typeparam name="M"></typeparam> /// <param name="dbType">数据库类型 DatabaseType</param> /// <param name="conn">数据库连结接口实例</param> /// <param name="decryptAlgorithm">解密算法</param> /// <returns></returns> public static IDbProvider <M> GetDbProvider <M>(string dbType, IDbConnectionString conn, IDecryptAlgorithm decryptAlgorithm = null) where M : IDbModel, new() { IDbProvider <M> instance = null; Type MT = typeof(M); if (!s_dbProviderCache.ContainsKey(MT)) { lock (s_dbProviderKey) { if (!s_dbProviderCache.ContainsKey(MT)) { if (!AtomicKernel.Dependency.IsRegistered <IDbProvider <M> >(dbType)) { throw new Exception("dbType is illegal"); } if (null == conn) { throw new ArgumentNullException("conn"); } //解析数据模型映射接口实例 IDbMappingHandler dbMapper = AtomicKernel.Dependency.Resolve <IDbMappingHandler>(); if (null == dbMapper) { throw new Exception("未能解析出IDbMappingHandler接口实例"); } //执行解密 string connStr = null; if (null == decryptAlgorithm) { connStr = conn.GetConnection(); } else { connStr = decryptAlgorithm.Decrypt(conn.GetConnection()); } //开始构造DAL(使用构造函数一) Dictionary <string, object> paramDic = new Dictionary <string, object> { { "dbConnQuery", connStr }, { "dbMappingHandler", dbMapper } }; instance = AtomicKernel.Dependency.Resolve <IDbProvider <M> >(dbType, paramDic.ToArray()); s_dbProviderCache.Add(MT, instance); } else { instance = s_dbProviderCache[MT] as IDbProvider <M>; } } } else { instance = s_dbProviderCache[MT] as IDbProvider <M>; } return(instance); }