public InMemoryDataStore(
            [NotNull] IModel model,
            [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
            [NotNull] IEntityMaterializerSource entityMaterializerSource,
            [NotNull] InMemoryDatabase persistentDatabase,
            [NotNull] IDbContextOptions options,
            [NotNull] ILoggerFactory loggerFactory)
            : base(
                Check.NotNull(model, nameof(model)),
                Check.NotNull(entityKeyFactorySource, nameof(entityKeyFactorySource)),
                Check.NotNull(entityMaterializerSource, nameof(entityMaterializerSource)),
                Check.NotNull(loggerFactory, nameof(loggerFactory)))
        {
            Check.NotNull(persistentDatabase, nameof(persistentDatabase));

            var storeConfig = options.Extensions
                              .OfType <InMemoryOptionsExtension>()
                              .FirstOrDefault();

            _persist = storeConfig?.Persist ?? true;

            _database = new ThreadSafeLazyRef <InMemoryDatabase>(
                () => _persist
                    ? persistentDatabase
                    : new InMemoryDatabase(loggerFactory));
        }
Пример #2
0
        public InMemoryDataStore(
            [NotNull] StateManager stateManager,
            [NotNull] DbContextService <IModel> model,
            [NotNull] EntityKeyFactorySource entityKeyFactorySource,
            [NotNull] EntityMaterializerSource entityMaterializerSource,
            [NotNull] ClrCollectionAccessorSource collectionAccessorSource,
            [NotNull] ClrPropertySetterSource propertySetterSource,
            [NotNull] InMemoryDatabase persistentDatabase,
            [NotNull] DbContextService <IDbContextOptions> options,
            [NotNull] ILoggerFactory loggerFactory)
            : base(stateManager, model, entityKeyFactorySource, entityMaterializerSource,
                   collectionAccessorSource, propertySetterSource, loggerFactory)
        {
            Check.NotNull(persistentDatabase, "persistentDatabase");

            var storeConfig = options.Service.Extensions
                              .OfType <InMemoryOptionsExtension>()
                              .FirstOrDefault();

            _persist = (storeConfig != null ? (bool?)storeConfig.Persist : null) ?? true;

            _database = new ThreadSafeLazyRef <InMemoryDatabase>(
                () => _persist
                    ? persistentDatabase
                    : new InMemoryDatabase(loggerFactory));
        }
        public InMemoryQueryContext(
            [NotNull] IModel model,
            [NotNull] ILogger logger,
            [NotNull] StateManager stateManager,
            [NotNull] InMemoryDatabase database)
            : base(model, logger, stateManager)
        {
            Check.NotNull(database, "database");

            _database = database;
        }
        public InMemoryDataStore(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] InMemoryDatabase persistentDatabase)
            : base(configuration)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(persistentDatabase, "persistentDatabase");

            var storeConfig = configuration.ContextOptions.Extensions
                              .OfType <InMemoryConfigurationExtension>()
                              .FirstOrDefault();

            _persist = (storeConfig != null ? (bool?)storeConfig.Persist : null) ?? true;

            _database = new ThreadSafeLazyRef <InMemoryDatabase>(
                () => _persist
                    ? persistentDatabase
                    : new InMemoryDatabase(configuration.LoggerFactory));
        }