public SqlDataProvider(string connectionString, IEnumerable <InterfaceConfigurationElement> interfaceConfigurationElement, SqlLoggingContext sqlLoggingContext = null) { _connectionString = connectionString; _interfaceConfigurationElements = interfaceConfigurationElement.ToList(); _sqlLoggingContext = sqlLoggingContext; }
internal SqlDataTypeStoresContainer(string providerName, string connectionString, SqlLoggingContext sqlLoggingContext = null) { _providerName = providerName; ConnectionString = connectionString; _sqlLoggingContext = sqlLoggingContext; }
public IDataProvider Assemble(IBuilderContext context, DataProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { var sqlDataProviderData = (SqlDataProviderData)objectConfiguration; string configFilePath = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.ConfigurationDirectory), string.Format("{0}.config", sqlDataProviderData.Name)); var configuration = new C1Configuration(configFilePath); var section = configuration.GetSection(SqlDataProviderConfigurationSection.SectionName) as SqlDataProviderConfigurationSection; if (section == null) { section = new SqlDataProviderConfigurationSection(); configuration.Sections.Add(SqlDataProviderConfigurationSection.SectionName, section); configuration.Save(); } var interfaceConfigurationElements = new List <InterfaceConfigurationElement>(); foreach (InterfaceConfigurationElement table in section.Interfaces) { interfaceConfigurationElements.Add(table); } var sqlLoggingContext = new SqlLoggingContext { Enabled = sqlDataProviderData.SqlQueryLoggingEnabled, IncludeStack = sqlDataProviderData.SqlQueryLoggingIncludeStack, TypesToIgnore = new List <Type>(), TablesToIgnore = new List <string>() }; if (sqlDataProviderData.SqlQueryLoggingEnabled) { foreach (LoggingIgnoreInterfacesConfigurationElement element in sqlDataProviderData.LoggingIgnoreInterfaces) { Type interfaceType = TypeManager.TryGetType(element.InterfaceType); if (interfaceType != null) { sqlLoggingContext.TypesToIgnore.Add(interfaceType); InterfaceConfigurationElement interfaceElement = interfaceConfigurationElements.SingleOrDefault(f => f.DataTypeId == interfaceType.GetImmutableTypeId()); if (interfaceElement == null) { continue; } foreach (StoreConfigurationElement store in interfaceElement.ConfigurationStores) { sqlLoggingContext.TablesToIgnore.Add(store.TableName); } } } } string connectionString = sqlDataProviderData.ConnectionString; if (string.IsNullOrEmpty(connectionString)) { string connectionStringName = sqlDataProviderData.ConnectionStringName; if (string.IsNullOrEmpty(connectionStringName)) { throw new ConfigurationErrorsException("SqlDataProvider requires one of the following properties to be specified: 'connectionString', 'connectionStringName'"); } var connStringConfigNode = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[connectionStringName]; Verify.IsNotNull(connStringConfigNode, "Failed to find an SQL connection string by name '{0}'", connectionStringName); connectionString = connStringConfigNode.ConnectionString; } return(new SqlDataProvider(connectionString, interfaceConfigurationElements, sqlLoggingContext)); }