Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbCurrentType">指定数据库类型:MySql/MsSql/PgSql</param>
 /// <param name="dbName">指定数据连串名称</param>
 /// <returns></returns>
 public static ISqlDapper GetSqlDapper(DbCurrentType dbCurrentType, string dbName = null)
 {
     if (dbName.IsNullOrEmpty())
     {
         return(new SqlDapper(dbName ?? DefaultConnName));
     }
     return(new SqlDapper(dbName, dbCurrentType));
 }
Пример #2
0
 /// <summary>
 /// 扩展dapper 获取MSSQL数据库DbConnection,默认系统获取配置文件的DBType数据库类型,
 /// </summary>
 /// <param name="connString">如果connString为null 执行重载GetDbConnection(string connString = null)</param>
 /// <param name="dapperType">指定连接数据库的类型:MySql/MsSql/PgSql</param>
 /// <returns></returns>
 public static IDbConnection GetDbConnection(string connString = null, DbCurrentType dbCurrentType = DbCurrentType.Default)
 {
     //默认获取DbConnection
     if (connString.IsNullOrEmpty() || DbCurrentType.Default == dbCurrentType)
     {
         return(GetDbConnection(connString));
     }
     if (dbCurrentType == DbCurrentType.MySql)
     {
         return(new MySql.Data.MySqlClient.MySqlConnection(connString));
     }
     if (dbCurrentType == DbCurrentType.PgSql)
     {
         return(new NpgsqlConnection(connString));
     }
     return(new SqlConnection(connString));
 }
Пример #3
0
 public SqlDapper(string connKeyName, DbCurrentType dbCurrentType)
 {
     _dbCurrentType    = dbCurrentType;
     _connectionString = DBServerProvider.GetConnectionString(connKeyName);
 }