//[InlineData(DbServer.Sqlite)] public async Task BulkInsertOrUpdate_EntityWithNestedObjectGraph_SavesGraphToDatabase(DbServer databaseType) { ContextUtil.DbServer = databaseType; using var db = new GraphDbContext(ContextUtil.GetOptions <GraphDbContext>(databaseName: $"{nameof(EFCoreBulkTest)}_Graph")); var testData = this.GetTestData(db).ToList(); await db.BulkInsertOrUpdateAsync(testData, new BulkConfig { IncludeGraph = true }); var workOrderQuery = db.WorkOrderSpares .Include(y => y.WorkOrder) .Include(y => y.WorkOrder.Asset) .Include(y => y.Spare); foreach (var wos in workOrderQuery) { Assert.NotNull(wos.WorkOrder); Assert.NotNull(wos.WorkOrder.Asset); Assert.NotNull(wos.Spare); } }
public void Dispose() { using var db = new GraphDbContext(ContextUtil.GetOptions <GraphDbContext>(databaseName: $"{nameof(EFCoreBulkTest)}_Graph")); db.Database.EnsureDeleted(); }
public void Dispose() { using var db = new VcDbContext(ContextUtil.GetOptions <VcDbContext>(databaseName: $"{nameof(EFCoreBulkTest)}_ValueConverters")); db.Database.EnsureDeleted(); }
public void Test_Mapping() { using (NT.XUnit.TestMeta.TestContext ctx = new NT.XUnit.TestMeta.TestContext(ContextUtil.GetOptions())) { DbMapping map = DbMapper.GetDbMapping(ctx); } }
public void Dispose() { using var db = new SpDbContext(ContextUtil.GetOptions <SpDbContext>(databaseName: $"{nameof(EFCoreBulkTest)}_ShadowProperties")); db.Database.EnsureDeleted(); }
public async Task Test(DbServer dbServer) { ContextUtil.DbServer = dbServer; using var db = new Issue547DbContext(ContextUtil.GetOptions <Issue547DbContext>(databaseName: $"{nameof(EFCoreBulkTest)}_Issue547")); await db.Database.EnsureCreatedAsync(); var tranches = new List <RootEntity> { new RootEntity { Id = 1, Owned = new OwnedType { Field1 = "F1", Child = new ChildEntity { Id = 1388, Name = "F1C1" } }, OwnedInSeparateTable = new OwnedInSeparateTable { Flowers = "Roses" } }, new RootEntity { Id = 2, Owned = new OwnedType { Field1 = "F2", Child = new ChildEntity { Id = 1234, Name = "F2C2" } }, OwnedInSeparateTable = new OwnedInSeparateTable { Flowers = "Tulips" } } }; await db.BulkInsertOrUpdateAsync(tranches, new BulkConfig { IncludeGraph = true }); foreach (var a in tranches) { Assert.True(a.Owned.ChildId.HasValue); } var rootEntities = await db.RootEntities .Include(y => y.OwnedInSeparateTable) .Include(y => y.Owned.Child) .ToListAsync(); foreach (var re in rootEntities) { Assert.NotNull(re.Owned); Assert.NotEmpty(re.Owned.Field1); Assert.NotNull(re.Owned.ChildId); Assert.NotNull(re.Owned.Child); Assert.NotEmpty(re.Owned.Child.Name); Assert.NotNull(re.OwnedInSeparateTable); Assert.NotEmpty(re.OwnedInSeparateTable.Flowers); } }