Example #1
0
 public CosmosSqlDatabase(
     [NotNull] DatabaseDependencies dependencies,
     DocumentCollectionUpdaterFactory documentCollectionFactory)
     : base(dependencies)
 {
     _documentCollectionFactory = documentCollectionFactory;
 }
 public InfoCarrierDatabase(
     DatabaseDependencies dependencies,
     IDbContextOptions options)
     : base(dependencies)
 {
     this.infoCarrierClient = options.Extensions.OfType <InfoCarrierOptionsExtension>().First().InfoCarrierClient;
 }
Example #3
0
 public CosmosDatabase(
     DatabaseDependencies dependencies,
     CosmosClient cosmosClient)
     : base(dependencies)
 {
     _cosmosClient = cosmosClient;
 }
 public MongoDbDatabase(
     [NotNull] DatabaseDependencies databaseDependencies,
     [NotNull] IMongoDbConnection mongoDbConnection)
     : base(Check.NotNull(databaseDependencies, nameof(databaseDependencies)))
 {
     _mongoDbConnection = Check.NotNull(mongoDbConnection, nameof(mongoDbConnection));
 }
Example #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RelationalDatabase" /> class.
 /// </summary>
 /// <param name="dependencies">Parameter object containing dependencies for the base of this service.</param>
 /// <param name="relationalDependencies">Parameter object containing relational dependencies for this service.</param>
 public RelationalDatabase(
     DatabaseDependencies dependencies,
     RelationalDatabaseDependencies relationalDependencies)
     : base(dependencies)
 {
     RelationalDependencies = relationalDependencies;
 }
 public CosmosSqlDatabase(
     [NotNull] DatabaseDependencies dependencies,
     CosmosClient cosmosClient,
     IDocumentCollectionFactory documentCollectionFactory)
     : base(dependencies)
 {
     _cosmosClient = cosmosClient;
     _documentCollectionFactory = documentCollectionFactory;
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of hte <see cref="MongoDbDatabase"/> class.
 /// </summary>
 /// <param name="databaseDependencies">Parameter object containing dependencies for this service.</param>
 /// <param name="mongoDbConnection">A <see cref="IMongoDbConnection"/> used to communicate with the MongoDB instance.</param>
 /// <param name="mongoDbWriteModelFactorySelector">The <see cref="IMongoDbWriteModelFactorySelector"/> to use to create
 /// <see cref="IMongoDbWriteModelFactory{TEntity}"/> instances.</param>
 public MongoDbDatabase(
     [NotNull] DatabaseDependencies databaseDependencies,
     [NotNull] IMongoDbConnection mongoDbConnection,
     [NotNull] IMongoDbWriteModelFactorySelector mongoDbWriteModelFactorySelector)
     : base(Check.NotNull(databaseDependencies, nameof(databaseDependencies)))
 {
     _mongoDbConnection = Check.NotNull(mongoDbConnection, nameof(mongoDbConnection));
     _mongoDbWriteModelFactorySelector = Check.NotNull(mongoDbWriteModelFactorySelector, nameof(mongoDbWriteModelFactorySelector));
 }
Example #8
0
        public CosmosDatabase(
            DatabaseDependencies dependencies,
            CosmosClient cosmosClient,
            ILoggingOptions loggingOptions)
            : base(dependencies)
        {
            _cosmosClient = cosmosClient;

            if (loggingOptions.IsSensitiveDataLoggingEnabled)
            {
                _sensitiveLoggingEnabled = true;
            }
        }
Example #9
0
        public static string ToSql <TEntity>(this IQueryable <TEntity> query, DbContext dbCtx)
        {
            IQueryModelGenerator        modelGenerator          = dbCtx.GetService <IQueryModelGenerator>();
            QueryModel                  queryModel              = modelGenerator.ParseQuery(query.Expression);
            DatabaseDependencies        databaseDependencies    = dbCtx.GetService <DatabaseDependencies>();
            QueryCompilationContext     queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false);
            RelationalQueryModelVisitor modelVisitor            = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor();

            modelVisitor.CreateQueryExecutor <TEntity>(queryModel);
            var sql = modelVisitor.Queries.First().ToString();

            return(sql);
        }
Example #10
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public CosmosDatabaseWrapper(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] CosmosClientWrapper cosmosClient,
            [NotNull] ILoggingOptions loggingOptions)
            : base(dependencies)
        {
            _cosmosClient = cosmosClient;

            if (loggingOptions.IsSensitiveDataLoggingEnabled)
            {
                _sensitiveLoggingEnabled = true;
            }
        }
Example #11
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public HarmonyDatabase(
     DatabaseDependencies dependencies,
     IDataObjectProvider dataProvider,
     IServiceProvider serviceProvider,
     IDbContextOptions options,
     IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
     : base(dependencies)
 {
     //_store = storeCache.GetStore(options);
     _updateLogger       = updateLogger;
     _dataObjectProvider = dataProvider;
     _serviceProvider    = serviceProvider;
 }
        public void Save_changes_returns_requested_document_count()
        {
            var queryCompilationContextFactory = Mock.Of <IQueryCompilationContextFactory>();
            var mockMongoDbConnection          = new Mock <IMongoDbConnection>();
            var mockStateManager                = new Mock <IStateManager>();
            var mockMongoCollection             = new Mock <IMongoCollection <SimpleRecord> >();
            var mockValueGenerationManager      = new Mock <IValueGenerationManager>();
            var mockInternalEntityEntryNotifier = new Mock <IInternalEntityEntryNotifier>();

            mockStateManager.SetupGet(stateManager => stateManager.ValueGeneration)
            .Returns(() => mockValueGenerationManager.Object);
            mockStateManager.SetupGet(stateManager => stateManager.Notify)
            .Returns(() => mockInternalEntityEntryNotifier.Object);
            mockMongoDbConnection.Setup(mockedMongoDbConnection => mockedMongoDbConnection.GetCollection <SimpleRecord>())
            .Returns(() => mockMongoCollection.Object);
            mockMongoCollection.Setup(mongoCollection => mongoCollection.BulkWrite(
                                          It.IsAny <IEnumerable <WriteModel <SimpleRecord> > >(),
                                          It.IsAny <BulkWriteOptions>(),
                                          It.IsAny <CancellationToken>()))
            .Returns((IEnumerable <WriteModel <SimpleRecord> > list, BulkWriteOptions options, CancellationToken token)
                     => new BulkWriteResult <SimpleRecord> .Acknowledged(
                         list.Count(),
                         matchedCount: 0,
                         deletedCount: list.OfType <DeleteOneModel <SimpleRecord> >().Count(),
                         insertedCount: list.OfType <InsertOneModel <SimpleRecord> >().Count(),
                         modifiedCount: list.OfType <ReplaceOneModel <SimpleRecord> >().Count(),
                         processedRequests: list,
                         upserts: new List <BulkWriteUpsert>()));
            var databaseDepedencies = new DatabaseDependencies(queryCompilationContextFactory);
            var mongoDbDatabase     = new MongoDbDatabase(databaseDepedencies, mockMongoDbConnection.Object);

            var        model      = new Model(new CoreConventionSetBuilder().CreateConventionSet());
            EntityType entityType = model.AddEntityType(typeof(SimpleRecord));

            entityType.Builder
            .GetOrCreateProperties(typeof(SimpleRecord).GetTypeInfo().GetProperties(), ConfigurationSource.Convention);
            entityType.Builder
            .MongoDb(ConfigurationSource.Convention)
            .FromCollection(collectionName: "simpleRecords");

            IReadOnlyList <InternalEntityEntry> entityEntries = new[] { EntityState.Added, EntityState.Deleted, EntityState.Modified }
            .Select(entityState =>
            {
                var entityEntry = new InternalClrEntityEntry(mockStateManager.Object, entityType, new SimpleRecord());
                entityEntry.SetEntityState(entityState, acceptChanges: true);
                return(entityEntry);
            })
            .ToList();

            Assert.Equal(entityEntries.Count, mongoDbDatabase.SaveChanges(entityEntries));
        }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public FileContextDatabase(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] IFileContextStoreCache storeCache,
            [NotNull] IDbContextOptions options,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeCache, nameof(storeCache));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store        = storeCache.GetStore(options.Extensions.OfType <FileContextOptionsExtension>().First());
            _updateLogger = updateLogger;
        }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public InMemoryDatabase(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] IInMemoryStoreSource storeSource,
            [NotNull] IDbContextOptions options,
            [NotNull] ILogger <InMemoryDatabase> logger)
            : base(dependencies)
        {
            Check.NotNull(storeSource, nameof(storeSource));
            Check.NotNull(options, nameof(options));
            Check.NotNull(logger, nameof(logger));

            _store  = storeSource.GetStore(options);
            _logger = logger;
        }
Example #15
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public InMemoryDatabase(
     DatabaseDependencies dependencies,
     IInMemoryStoreCache storeCache,
     IDbContextOptions options,
     IDesignTimeModel designTimeModel,
     IUpdateAdapterFactory updateAdapterFactory,
     IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
     : base(dependencies)
 {
     _store                = storeCache.GetStore(options);
     _designTimeModel      = designTimeModel;
     _updateAdapterFactory = updateAdapterFactory;
     _updateLogger         = updateLogger;
 }
Example #16
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public InMemoryDatabase(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] IInMemoryStoreSource storeSource,
            [NotNull] IDbContextOptions options,
            [NotNull] IInterceptingLogger <LoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeSource, nameof(storeSource));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store        = storeSource.GetStore(options);
            _updateLogger = updateLogger;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LiteDBDatabase"/> class.
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public LiteDBDatabase(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] ILiteDBStoreCache storeCache,
            [NotNull] IDbContextOptions options,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeCache, nameof(storeCache));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store        = storeCache.GetStore(options);
            _updateLogger = updateLogger;
        }
Example #18
0
        public static string ToSql <TEntity>(this IQueryable <TEntity> query) where TEntity : class
        {
            QueryCompiler       queryCompiler  = (QueryCompiler)QueryCompilerField.GetValue(query.Provider);
            QueryModelGenerator modelGenerator = (QueryModelGenerator)QueryModelGeneratorField.GetValue(queryCompiler);

            Remotion.Linq.QueryModel queryModel                 = modelGenerator.ParseQuery(query.Expression);
            IDatabase                   database                = (IDatabase)DataBaseField.GetValue(queryCompiler);
            DatabaseDependencies        databaseDependencies    = (DatabaseDependencies)DatabaseDependenciesField.GetValue(database);
            QueryCompilationContext     queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false);
            RelationalQueryModelVisitor modelVisitor            = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor();

            modelVisitor.CreateQueryExecutor <TEntity>(queryModel);
            string sql = modelVisitor.Queries.First().ToString();

            return(sql);
        }
        public GDbDatabase(
            DatabaseDependencies databaseDependencies,
            IGDbStoreCache gDbStoreCache,
            IDbContextOptions dbContextOptions,
            IDiagnosticsLogger <DbLoggerCategory.Update> diagnosticsLogger,
            IGDbQueryExecutorFactory gDbQueryBuilderFactory)
            : base(
                databaseDependencies)
        {
            _gDbStore
                = gDbStoreCache
                  .GetStore(
                      dbContextOptions,
                      gDbQueryBuilderFactory);

            _diagnosticsLogger = diagnosticsLogger;
        }
Example #20
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public InMemoryDatabase(
            [NotNull] DatabaseDependencies dependencies,
            [NotNull] IInMemoryStoreCache storeCache,
            [NotNull] IDbContextOptions options,
            [NotNull] IUpdateAdapterFactory updateAdapterFactory,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeCache, nameof(storeCache));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store = storeCache.GetStore(options);
            _updateAdapterFactory = updateAdapterFactory;
            _updateLogger         = updateLogger;
        }
Example #21
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public InMemoryDatabase(
            DatabaseDependencies dependencies,
            IInMemoryStoreCache storeCache,
            IDbContextOptions options,
            ICurrentDbContext context,
            IUpdateAdapterFactory updateAdapterFactory,
            IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
            : base(dependencies)
        {
            Check.NotNull(storeCache, nameof(storeCache));
            Check.NotNull(options, nameof(options));
            Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory));
            Check.NotNull(updateLogger, nameof(updateLogger));

            _store                = storeCache.GetStore(options);
            _getDesignModel       = () => context.Context.DesignTimeModel;
            _updateAdapterFactory = updateAdapterFactory;
            _updateLogger         = updateLogger;
        }
Example #22
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Database" /> class.
 /// </summary>
 /// <param name="dependencies">Parameter object containing dependencies for this service.</param>
 protected Database(DatabaseDependencies dependencies)
 {
     Dependencies = dependencies;
 }
 public IndexedDbDatabase(DatabaseDependencies dependencies)
     : base(dependencies)
 {
 }
Example #24
0
 protected LocalDbDatabase(DatabaseDependencies dependencies) :
     base(dependencies)
 {
 }
Example #25
0
 public SimpleDatabase(DatabaseDependencies dependencies)
     : base(dependencies)
 {
 }
Example #26
0
 public RocksDbDatabase(DatabaseDependencies dependencies)
     : base(dependencies)
 {
 }