public DataProviderBase InvalidateDataProvider(DataProviderBase dataProvider, string configuration, string connectionString) { var dataProviderType = dataProvider.GetType(); if (!_providers.ContainsKey(dataProviderType)) { throw new InvalidOperationException( string.Format(Resources.DataProviderVersionResolverBase_ProviderIsNotRegistered, dataProvider.UniqueName, dataProviderType.FullName)); } DataProviderBase result; if (_providersToStrings.TryGetValue(connectionString, out result)) return result; lock (_providersToStrings) { if (_providersToStrings.TryGetValue(connectionString, out result)) return result; result = InvalidateDataProviderInternal(dataProvider, configuration, connectionString); if (result != null) _providersToStrings.Add(connectionString, result); } return result; }
public DataProviderBase InvalidateDataProvider(DataProviderBase dataProvider, string configuration, string connectionString) { var dataProviderType = dataProvider.GetType(); if (!_providers.ContainsKey(dataProviderType)) { throw new InvalidOperationException( string.Format(Resources.DataProviderVersionResolverBase_ProviderIsNotRegistered, dataProvider.UniqueName, dataProviderType.FullName)); } DataProviderBase result; if (_providersToStrings.TryGetValue(connectionString, out result)) { return(result); } lock (_providersToStrings) { if (_providersToStrings.TryGetValue(connectionString, out result)) { return(result); } result = InvalidateDataProviderInternal(dataProvider, configuration, connectionString); if (result != null) { _providersToStrings.Add(connectionString, result); } } return(result); }
protected override DataProviderBase InvalidateDataProviderInternal(DataProviderBase dataProvider, string configuration, string connectionString) { Type type = DefaultProviderType; try { int?configVersion = GetVersionFromConfiguration(configuration); int?serverVersion = null; int?compatibilityLevel = null; int?targetVersion = null; using (var connection = (SqlConnection)dataProvider.CreateConnectionObject()) { connection.ConnectionString = connectionString; connection.Open(); serverVersion = GetVersionFromConnection(connection); if (serverVersion >= Sql2005) { compatibilityLevel = GetDatabaseCompatibilityLevel(connection); } } targetVersion = compatibilityLevel ?? configVersion ?? serverVersion; if (targetVersion >= Sql2012) { type = typeof(Sql2012DataProvider); } else if (targetVersion == Sql2008) { type = typeof(Sql2008DataProvider); } else if (targetVersion == Sql2005) { type = typeof(Sql2005DataProvider); } else if (targetVersion == Sql2000) { type = typeof(Sql2000DataProvider); } } catch { return(null); } return(GetProviderByType(type)); }
public void AddDataProvider(DataProviderBase dataProvier) { if (dataProvier == null) throw new ArgumentNullException("dataProvier"); var providerType = dataProvier.GetType(); if (!TypeHelper.IsSameOrParent(_baseProviderType, providerType)) throw new ArgumentException( string.Format(Resources.DataProviderVersionResolverBase_InvalidProviderType, providerType.FullName, _baseProviderType.FullName)); lock (_providers) { _providers[providerType] = dataProvier; } }
public void AddDataProvider(DataProviderBase dataProvier) { if (dataProvier == null) { throw new ArgumentNullException("dataProvier"); } var providerType = dataProvier.GetType(); if (!TypeHelper.IsSameOrParent(_baseProviderType, providerType)) { throw new ArgumentException( string.Format(Resources.DataProviderVersionResolverBase_InvalidProviderType, providerType.FullName, _baseProviderType.FullName)); } lock (_providers) { _providers[providerType] = dataProvier; } }
protected override DataProviderBase InvalidateDataProviderInternal(DataProviderBase dataProvider, string configuration, string connectionString) { Type type = DefaultProviderType; try { int? configVersion = GetVersionFromConfiguration(configuration); int? serverVersion = null; int? compatibilityLevel = null; int? targetVersion = null; using (var connection = (SqlConnection) dataProvider.CreateConnectionObject()) { connection.ConnectionString = connectionString; connection.Open(); serverVersion = GetVersionFromConnection(connection); if (serverVersion >= Sql2005) compatibilityLevel = GetDatabaseCompatibilityLevel(connection); } targetVersion = compatibilityLevel ?? configVersion ?? serverVersion; if (targetVersion >= Sql2012) type = typeof(Sql2012DataProvider); else if (targetVersion == Sql2008) type = typeof(Sql2008DataProvider); else if (targetVersion == Sql2005) type = typeof(Sql2005DataProvider); else if (targetVersion == Sql2000) type = typeof(Sql2000DataProvider); } catch { return null; } return GetProviderByType(type); }
protected abstract DataProviderBase InvalidateDataProviderInternal(DataProviderBase dataProvider, string configuration, string connectionString);
protected abstract DataProviderBase InvalidateDataProviderInternal(DataProviderBase dataProvider, string configuration, string connectionString);
public virtual void Initialize(string providerName, string connString) { dp = DbManager.GetDataProvider(providerName); this.connString = connString; }
public virtual DbManager CreateDbManager(DataProviderBase provider, string connectionString) { return new DbManager(provider, connectionString); }