public static DataAdapter CreateSelectDataAdapter(DbCommand cmd) { var adapter = DbProviderFactoryFactory.GetInstance().CreateDataAdapter(); adapter.SelectCommand = cmd; return(adapter); }
public static DbConnection Create(string connStr) { DbProviderFactory factory = DbProviderFactoryFactory.GetInstance(); DbConnection conn = factory.CreateConnection(); conn.ConnectionString = connStr; return(conn); }
/// <summary> /// Create DbParameter using the configured DbFactory /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <returns></returns> public static DbParameter CreateParameter(string name, object value) { DbParameter param = DbProviderFactoryFactory.Create().CreateParameter(); param.Value = value; param.ParameterName = name; return(param); }
public void Setup() { if (String.IsNullOrEmpty(ConfigPath)) { ConfigPath = "SmartSqlMapConfig.xml"; } if (LoggerFactory == null) { LoggerFactory = NoneLoggerFactory.Instance; } if (ConfigLoader == null) { ConfigLoader = new LocalFileConfigLoader(ConfigPath, LoggerFactory); } var sqlMapConfig = ConfigLoader.Load(); SmartSqlContext = new SmartSqlContext(LoggerFactory.CreateLogger <SmartSqlContext>(), sqlMapConfig); if (DbSessionStore == null) { var dbProviderFactory = DbProviderFactoryFactory.Create(SmartSqlContext.DbProvider.Type); DbSessionStore = new DbConnectionSessionStore(LoggerFactory, dbProviderFactory); } if (DataSourceFilter == null) { DataSourceFilter = new DataSourceFilter(LoggerFactory.CreateLogger <DataSourceFilter>(), DbSessionStore, SmartSqlContext); } if (SqlBuilder == null) { SqlBuilder = new SqlBuilder(LoggerFactory.CreateLogger <SqlBuilder>(), SmartSqlContext); } if (PreparedCommand == null) { PreparedCommand = new PreparedCommand(LoggerFactory.CreateLogger <PreparedCommand>(), SmartSqlContext); } if (CommandExecuter == null) { CommandExecuter = new CommandExecuter(LoggerFactory.CreateLogger <CommandExecuter>(), PreparedCommand); } if (DataReaderDeserializerFactory == null) { DataReaderDeserializerFactory = new EmitDataReaderDeserializerFactory(); } if (CacheManager == null) { if (SmartSqlContext.IsCacheEnabled) { CacheManager = new CacheManager(LoggerFactory.CreateLogger <CacheManager>(), SmartSqlContext, DbSessionStore); } else { CacheManager = new NoneCacheManager(); } } ConfigLoader.OnChanged += ConfigLoader_OnChanged; }
/// <summary> /// Create DbParameter using the configured DbFactory /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <returns></returns> public static DbParameter CreateParameter(string name, object value, SqlDbType dbType) { DbParameter param = DbProviderFactoryFactory.GetInstance().CreateParameter(); param.Value = value; param.ParameterName = name; //param.DbType = (DbType)dbType; return(param); }