Here are the examples of the csharp api class System.Data.Common.DbProviderFactories.GetFactory(System.Data.Common.DbConnection) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
31 Examples
0
1. Example
View licenseinternal static DbProviderFactory GetProviderFactory(string providerInvariantName) { EntityUtil.CheckArgumentNull(providerInvariantName, "providerInvariantName"); DbProviderFactory factory; try { factory = DbProviderFactories.GetFactory(providerInvariantName); } catch (ArgumentException e) { throw EntityUtil.Argument(Strings.EntityClient_InvalidStoreProvider, e); } return factory; }
0
2. Example
View licenseprivate DbProviderFactory GetFactory(string providerString) { try { return DbProviderFactories.GetFactory(providerString); } catch (ArgumentException e) { throw EntityUtil.Argument(System.Data.Entity.Strings.EntityClient_InvalidStoreProvider, e); } }
0
3. Example
View licenseprotected virtual DbProviderFactory GetDbProviderFactory() { string providerName = ProviderName; // Default to SQL provider if (String.IsNullOrEmpty(providerName)) { // use DefaultProviderName instance return SqlClientFactory.Instance; } else { return DbProviderFactories.GetFactory(providerName); } }
0
4. Example
View licensepublic static DatabaseManager CreateFromConnectionStringName(string connectionStringName) { var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; var provider = DbProviderFactories.GetFactory(ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName); var manager = new DatabaseManager { _connectionString = connectionString, Provider = provider }; if (manager.Provider == null) throw new ArgumentException("Provider is a required component of the connection string.", nameof(connectionStringName)); return manager; }
0
5. Example
View licensepublic static DbProviderFactory GetFactory(DbKind dbKind) { var name = dbKind.GetProviderName(); return DbProviderFactories.GetFactory(name); }
0
6. Example
View licensepublic static DbProviderFactory GetDbProviderFactory(this System.Data.Entity.Database database) { Check.NotNull(database); DbConnection connection = database.Connection; DbProviderFactory factory = DbProviderFactories.GetFactory(connection); return factory; }
0
7. Example
View licensepublic static DbProviderFactory GetProviderFactory(DbConnection connection) { EntityUtil.CheckArgumentNull(connection, "connection"); DbProviderFactory factory = DbProviderFactories.GetFactory(connection); if (factory == null) { throw EntityUtil.ProviderIncompatible(System.Data.Entity.Strings.EntityClient_ReturnedNullOnProviderMethod( "get_ProviderFactory", connection.GetType().ToString())); } Debug.Assert(factory != null, "Should have thrown on null"); return factory; }
0
8. Example
View licensepublic static EntityConnection CreateStoreSchemaConnection(string providerInvariantName, string conn/n ..... /n //View Source file for more details /n }
0
9. Example
View licenseprivate DbConnection GetDbConnection(EntityConnectionStringBuilder connStrBuilder) { /n ..... /n //View Source file for more details /n }
0
10. Example
View licensepublic DbParameter CreateParameter() { if (_dbProviderFactory == null) { _dbProviderFactory = DbProviderFactories.GetFactory(Database.ProviderName); } return _dbProviderFactory.CreateParameter(); }
0
11. Example
View licenseinternal static bool ConnectionStringEquals(DbConnection connection, string connectionString) { DbProviderFactory factory = DbProviderFactories.GetFactory(connection); DbConnectionStringEqualityComparer comparer = GetConnectionStringEqualityComparer(factory); return comparer.Equals(connection.ConnectionString, connectionString); }
0
12. Example
View licenseprotected void StartServersStateScanIfNeed(System.Data.Entity.DbContext context) { lock (this._locker) { if (this._taskIsRunning) return; Type contextType = context.GetType(); DbProviderFactory factory = DbProviderFactories.GetFactory(context.Database.Connection); this.Config.StartDbServersStateScanTaskIfNeed(factory); this._taskIsRunning = true; } }
0
13. Example
View licenseprivate IDbConnection GetConnection() { var factory = DbProviderFactories.GetFactory(configuration.ProviderName); var connection = factory.CreateConnection(); connection.ConnectionString = configuration.ConnectionString; connection.Open(); return connection; }
0
14. Example
View licenseDbCommandBuilder CreateCommandBuilder(string providerInvariantName) { DbConnection dbConn = this.Connection as DbConnection; DbProviderFactory factory = ((dbConn != null) ? DbProviderFactories.GetFactory(dbConn) : null) ?? GetProviderFactory(providerInvariantName); return factory.CreateCommandBuilder(); }
0
15. Example
View licenseprivate DbParameter CreateSqlParameter() { Logger.Instance.WriteMethodEntry(Even/n ..... /n //View Source file for more details /n }
0
16. Example
View licenseprivate static DbProviderFactory GetProvider(string providerName) { bool hasProvider = DbProviderFactories.GetFactoryClasses().Rows.OfType<DataRow>() .Select(r => (string)r["InvariantName"]) .Contains(providerName, StringComparer.OrdinalIgnoreCase); if (hasProvider) { return DbProviderFactories.GetFactory(providerName); } return null; }
0
17. Example
View licensepublic DbConnection GetConnection() { if (_dbProviderFactory == null) { _dbProviderFactory = DbProviderFactories.GetFactory(Database.ProviderName); } var conn = _dbProviderFactory.CreateConnection(); Debug.Assert(conn != null, "conn != null"); conn.ConnectionString = ConnString; return conn; }
0
18. Example
View licenseprivate bool ConnectionStringCompare(DbConnection conn, string connectionString) { DbProviderFactory factory = DbProviderFactories.GetFactory(conn); DbConnectionStringBuilder a = factory.CreateConnectionStringBuilder(); a.ConnectionString = conn.ConnectionString; DbConnectionStringBuilder b = factory.CreateConnectionStringBuilder(); b.ConnectionString = connectionString; return a.EquivalentTo(b); }
0
19. Example
View licenseprivate void CommonConstruct() { // Reset _transactionDepth = 0; EnableAutoSelect = true; EnableNamedParams = true; // If a provider name was supplied, get the IDbProviderFactory for it if (_providerName != null) _factory = DbProviderFactories.GetFactory(_providerName); // Resolve the DB Type string DBTypeName = (_factory == null ? _sharedConnection.GetType() : _factory.GetType()).Name; _dbType = DatabaseType.Resolve(DBTypeName, _providerName); // What character is used for delimiting parameters in SQL _paramPrefix = _dbType.GetParameterPrefix(_connectionString); }
0
20. Example
View licensepublic static bool IsConnectionAvailable(string connString, DatabaseProviders provider) { DbProviderFactory factory; switch (provider) { case DatabaseProviders.SqlServer: case DatabaseProviders.SqlAzure: factory = DbProviderFactories.GetFactory(Constants.DatabaseProviders.SqlServer); break; case DatabaseProviders.SqlServerCE: factory = DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0"); break; case DatabaseProviders.MySql: factory = DbProviderFactories.GetFactory(Constants.DatabaseProviders.MySql); break; case DatabaseProviders.PostgreSQL: case DatabaseProviders.Oracle: case DatabaseProviders.SQLite: default: throw new NotSupportedException("The provider " + provider + " is not supported"); } var conn = factory.CreateConnection(); if (conn == null) { throw new InvalidOperationException("Could not create a connection for provider " + provider); } conn.ConnectionString = connString; using (var connection = conn) { return connection.IsAvailable(); } }
0
21. Example
View license[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] internal sta/n ..... /n //View Source file for more details /n }
0
22. Example
View licensepublic bool CheckDbConnection() { // // Clear all pool connected (connection without reference address) SqlConnection.ClearAllPools(); // // Check connection string validation if (string.IsNullOrEmpty(ConnectionString) || !IsServerOnline()) return IsReady = false; // // Try to Create provider factory for connect to Database try { DbProviderFactories.GetFactory(Connection.ProviderName); } catch { return IsReady = false; } // // try to connection to database and open link: try { Open(); IsReady = (State == ConnectionState.Open); } catch { IsReady = false; } finally { Close(); } return IsReady; }
0
23. Example
View licensepublic async Task<bool> CheckDbConnectionAsync() { // // Clear all pool connected (connection without reference address) SqlConnection.ClearAllPools(); // // Check connection string validation if (string.IsNullOrEmpty(ConnectionString) || !await IsServerOnlineAsync()) return IsReady = false; // // Try to Create provider factory for connect to Database try { DbProviderFactories.GetFactory(Connection.ProviderName); } catch { return IsReady = false; } // // try to connection to database and open link: try { await OpenAsync(); IsReady = (State == ConnectionState.Open); } catch { IsReady = false; } finally { Close(); } return IsReady; }
0
24. Example
View licensepublic static DbConnection GetDbConnection(this ConnectionStringSettings connectionStringSettings) { if (connectionStringSettings == null) { throw new SpiderException("ConnectionStringSetting is null."); } if (string.IsNullOrEmpty(connectionStringSettings.ConnectionString) || string.IsNullOrEmpty(connectionStringSettings.ProviderName)) { throw new SpiderException("ConnectionStringSetting is incorrect."); } var factory = DbProviderFactories.GetFactory(connectionStringSettings.ProviderName); for (int i = 0; i < 5; ++i) { try { DbConnection connection = factory.CreateConnection(); if (connection != null) { connection.ConnectionString = connectionStringSettings.ConnectionString; connection.Open(); return connection; } } catch (Exception e) { if (e.Message.ToLower().StartsWith("authentication to host")) { Logger.AllLog($"{e}", LogLevel.Error); Thread.Sleep(1000); } else { //throw; } } } throw new SpiderException("Can't get db connection."); }
0
25. Example
View license[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Reviewed/n ..... /n //View Source file for more details /n }
0
26. Example
View licensepublic virtual Int32 SaveChanges(SaveOptions options) { ObjectStateManager.Asser/n ..... /n //View Source file for more details /n }
0
27. Example
View licensepublic IEnumerable<IList<CellData>> Rows() { var factory = DbProvide/n ..... /n //View Source file for more details /n }
0
28. Example
View license[SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities", Jus/n ..... /n //View Source file for more details /n }
0
29. Example
View licensepublic override bool Run() { DbConnection db = Get(); if (db == null/n ..... /n //View Source file for more details /n }
0
30. Example
View licenseprivate IList<IList<dynamic>> ExecuteCommands() { Contract.Requires(/n ..... /n //View Source file for more details /n }
0
31. Example
View licenseprivate IList<IList<dynamic>> ExecuteCommands() { Contract.Requires(/n ..... /n //View Source file for more details /n }