private void BuildServices() { var services = context.Services; var configuration = context.Configuration; services.Configuration = configuration; services.IndexFilterCompiler = new PartialIndexFilterCompiler(); if (context.ParentDomain == null) { var descriptor = ProviderDescriptor.Get(configuration.ConnectionInfo.Provider); var driverFactory = (SqlDriverFactory)Activator.CreateInstance(descriptor.DriverFactory); var handlerFactory = (HandlerFactory)Activator.CreateInstance(descriptor.HandlerFactory); var driver = StorageDriver.Create(driverFactory, configuration); services.HandlerFactory = handlerFactory; services.StorageDriver = driver; services.NameBuilder = new NameBuilder(configuration, driver.ProviderInfo); } else { var handlers = context.ParentDomain.Handlers; services.HandlerFactory = handlers.Factory; services.StorageDriver = handlers.StorageDriver; services.NameBuilder = handlers.NameBuilder; } CreateConnection(services); context.DefaultSchemaInfo = defaultSchemaInfo = services.StorageDriver.GetDefaultSchema(services.Connection); services.MappingResolver = MappingResolver.Create(configuration, context.NodeConfiguration, defaultSchemaInfo); BuildExternalServices(services, configuration); services.Lock(); context.TypeIdProvider = new TypeIdProvider(context); }
private static SqlDriver CreateDriverInstance(string connectionString, bool isAzure, Version version, DefaultSchemaInfo defaultSchema, ErrorMessageParser parser, bool isEnsureAlive) { var builder = new SqlConnectionStringBuilder(connectionString); var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = builder.MultipleActiveResultSets, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (isAzure) { return(new Azure.Driver(coreServerInfo, parser, isEnsureAlive)); } if (version.Major < 9) { throw new NotSupportedException(Strings.ExSqlServerBelow2005IsNotSupported); } return(version.Major switch { 9 => new v09.Driver(coreServerInfo, parser, isEnsureAlive), 10 => new v10.Driver(coreServerInfo, parser, isEnsureAlive), 11 => new v11.Driver(coreServerInfo, parser, isEnsureAlive), 12 => new v12.Driver(coreServerInfo, parser, isEnsureAlive), 13 => new v13.Driver(coreServerInfo, parser, isEnsureAlive), _ => new v13.Driver(coreServerInfo, parser, isEnsureAlive) });
private static SqlDriver CreateDriverInstance( string connectionString, Version version, DefaultSchemaInfo defaultSchema) { var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = false, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 8 || (version.Major == 8 && version.Minor < 3)) { throw new NotSupportedException(Strings.ExPostgreSqlBelow83IsNotSupported); } // We support 8.3, 8.4 and any 9.0+ if (version.Major == 8) { return(version.Minor == 3 ? new v8_3.Driver(coreServerInfo) : new v8_4.Driver(coreServerInfo)); } if (version.Major == 9) { return(version.Minor == 0 ? new v9_0.Driver(coreServerInfo) : new v9_1.Driver(coreServerInfo)); } if (version.Major < 12) { return(new v10_0.Driver(coreServerInfo)); } return(new v12_0.Driver(coreServerInfo)); }
// Constructors internal BuildingContext(DomainBuilderConfiguration builderConfiguration) { ArgumentValidator.EnsureArgumentNotNull(builderConfiguration, "builderConfiguration"); BuilderConfiguration = builderConfiguration; PairedAssociations = new List <Pair <AssociationInfo, string> >(); DiscardedAssociations = new HashSet <AssociationInfo>(); ModelInspectionResult = new ModelInspectionResult(); DependencyGraph = new Graph <TypeDef>(); Modules = BuilderConfiguration.Services.Modules.ToList().AsReadOnly(); Modules2 = Modules.OfType <IModule2>().ToList().AsReadOnly(); Validator = new Validator(builderConfiguration.Services.ProviderInfo.SupportedTypes); DefaultSchemaInfo = builderConfiguration.DefaultSchemaInfo; }
public static MappingResolver Create(DomainConfiguration configuration, NodeConfiguration nodeConfiguration, DefaultSchemaInfo defaultSchemaInfo) { ArgumentValidator.EnsureArgumentNotNull(configuration, "configuration"); ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, "nodeConfiguration"); ArgumentValidator.EnsureArgumentNotNull(defaultSchemaInfo, "defaultSchemaInfo"); if (configuration.IsMultidatabase) { return(new MultidatabaseMappingResolver(configuration, nodeConfiguration)); } if (configuration.IsMultischema) { return(new MultischemaMappingResolver(configuration, nodeConfiguration, defaultSchemaInfo)); } return(new SimpleMappingResolver(defaultSchemaInfo)); }
private static SqlDriver CreateDriverInstance(string connectionString, Version version, DefaultSchemaInfo defaultSchema) { var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = false, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 3) { throw new NotSupportedException(Strings.ExSqlLiteServerBelow3IsNotSupported); } return(new v3.Driver(coreServerInfo)); }
private async ValueTask BuildServices(bool isAsync, CancellationToken token = default) { var services = context.Services; var configuration = context.Configuration; services.Configuration = configuration; services.IndexFilterCompiler = new PartialIndexFilterCompiler(); if (context.ParentDomain == null) { var descriptor = ProviderDescriptor.Get(configuration.ConnectionInfo.Provider); var driverFactory = (SqlDriverFactory)Activator.CreateInstance(descriptor.DriverFactory); var handlerFactory = (HandlerFactory)Activator.CreateInstance(descriptor.HandlerFactory); var driver = isAsync ? await StorageDriver.CreateAsync(driverFactory, configuration, token).ConfigureAwait(false) : StorageDriver.Create(driverFactory, configuration); services.HandlerFactory = handlerFactory; services.StorageDriver = driver; services.NameBuilder = new NameBuilder(configuration, driver.ProviderInfo); } else { var handlers = context.ParentDomain.Handlers; services.HandlerFactory = handlers.Factory; services.StorageDriver = handlers.StorageDriver; services.NameBuilder = handlers.NameBuilder; } await CreateConnection(services, isAsync, token).ConfigureAwait(false); context.DefaultSchemaInfo = defaultSchemaInfo = isAsync ? await services.StorageDriver.GetDefaultSchemaAsync(services.Connection, token).ConfigureAwait(false) : services.StorageDriver.GetDefaultSchema(services.Connection); services.MappingResolver = MappingResolver.Create(configuration, context.NodeConfiguration, defaultSchemaInfo); BuildExternalServices(services, configuration); services.Lock(); context.TypeIdProvider = new TypeIdProvider(context); }
// Constructors public MultischemaMappingResolver(DomainConfiguration configuration, NodeConfiguration nodeConfiguration, DefaultSchemaInfo defaultSchemaInfo) { schemaMapping = nodeConfiguration.SchemaMapping; defaultSchema = configuration.DefaultSchema; extractionTasks = configuration.MappingRules .Select(r => r.Schema) .Where(s => !string.IsNullOrEmpty(s)) .Concat(Enumerable.Repeat(configuration.DefaultSchema, 1)) .Distinct() .Select(s => new SqlExtractionTask(defaultSchemaInfo.Database, schemaMapping.Apply(s))) .ToList(); reversedSchemaMapping = new NameMappingCollection(); foreach (var mapping in schemaMapping) { reversedSchemaMapping.Add(mapping.Value, mapping.Key); } metadataTask = new SqlExtractionTask(defaultSchemaInfo.Database, schemaMapping.Apply(defaultSchema)); }
private static SqlDriver CreateDriverInstance( string connectionString, Version version, DefaultSchemaInfo defaultSchema) { var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = true, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (coreServerInfo.ServerVersion < new Version(2, 5)) { throw new NotSupportedException(Strings.ExFirebirdBelow25IsNotSupported); } if (coreServerInfo.ServerVersion.Major == 2 && coreServerInfo.ServerVersion.Minor == 5) { return(new v2_5.Driver(coreServerInfo)); } return(null); }
private static SqlDriver CreateDriverInstance(string connectionString, Version version, DefaultSchemaInfo defaultSchema) { var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = false, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 5) { throw new NotSupportedException(Strings.ExMySqlBelow50IsNotSupported); } return(version.Major switch { 5 when version.Minor == 0 => new v5_0.Driver(coreServerInfo), 5 when version.Minor == 1 => new v5_1.Driver(coreServerInfo), 5 when version.Minor == 5 => new v5_5.Driver(coreServerInfo), 5 when version.Minor == 6 => new v5_6.Driver(coreServerInfo), _ => new v5_6.Driver(coreServerInfo) });
// Constructors internal Domain(DomainConfiguration configuration, object upgradeContextCookie, SqlConnection singleConnection, DefaultSchemaInfo defaultSchemaInfo) { Configuration = configuration; Handlers = new HandlerAccessor(this); GenericKeyFactories = new ConcurrentDictionary <TypeInfo, GenericKeyFactory>(); RecordSetReader = new RecordSetReader(this); KeyGenerators = new KeyGeneratorRegistry(); PrefetchFieldDescriptorCache = new ConcurrentDictionary <TypeInfo, ReadOnlyList <PrefetchFieldDescriptor> >(); KeyCache = new LruCache <Key, Key>(Configuration.KeyCacheSize, k => k); QueryCache = new LruCache <object, Pair <object, TranslatedQuery> >(Configuration.QueryCacheSize, k => k.First); PrefetchActionMap = new Dictionary <TypeInfo, Action <SessionHandler, IEnumerable <Key> > >(); Extensions = new ExtensionCollection(); UpgradeContextCookie = upgradeContextCookie; SingleConnection = singleConnection; StorageNodeManager = new StorageNodeManager(Handlers); }
private static SqlDriver CreateDriverInstance(string connectionString, Version version, DefaultSchemaInfo defaultSchema) { var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = true, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 9 || (version.Major == 9 && version.Minor < 2)) { throw new NotSupportedException(Strings.ExOracleBelow9i2IsNotSupported); } return(version.Major switch { 9 => new v09.Driver(coreServerInfo), 10 => new v10.Driver(coreServerInfo), _ => new v11.Driver(coreServerInfo) });
// Constructors public SimpleMappingResolver(DefaultSchemaInfo defaultSchemaInfo) { extractionTask = new SqlExtractionTask(defaultSchemaInfo.Database, defaultSchemaInfo.Schema); }