//[ClassCleanup] static public void CleanUp() { using (var dbContext = new SmartlinkDbContext()) { dbContext.DestinationPoints.RemoveRange(dbContext.DestinationPoints.Where(o => o.Catalog.Name.StartsWith("https://cand3.onmicrosoft.com/test/DestinationCatalog"))); dbContext.DestinationCatalogs.RemoveRange(dbContext.DestinationCatalogs.Where(o => o.Name.StartsWith("https://cand3.onmicrosoft.com/test/DestinationCatalog"))); dbContext.SourcePoints.RemoveRange(dbContext.SourcePoints.Where(o => o.Name.StartsWith("SourcePoint"))); dbContext.SourceCatalogs.RemoveRange(dbContext.SourceCatalogs.Where(o => o.Name.StartsWith("https://cand3.onmicrosoft.com/test/SourceCatalog"))); dbContext.SaveChanges(); } }
public void TestInsertSourceCategory() { var dbContext = new SmartlinkDbContext(); dbContext.SourceCatalogs.Add(new Entity.SourceCatalog() { Name = "First One" }); dbContext.SaveChanges(); dbContext.SourceCatalogs.ToList().ForEach(o => { System.Console.WriteLine("SourceCatalog Id:{0}\tName:{1}", o.Id, o.Name); }); }
static private void InitDatabase() { var dbContext = new SmartlinkDbContext(); var SourceCatalog = new SourceCatalog() { Name = "https://cand3.onmicrosoft.com/test/SourceCatalog1.xlsx" }; dbContext.SourceCatalogs.Add(SourceCatalog); var sourcePoints = new SourcePoint[500]; var destinationCatalog = new DestinationCatalog[500]; for (int i = 0; i < 500; i++) { sourcePoints[i] = new SourcePoint() { Name = $"SourcePoint{i}", Catalog = SourceCatalog, RangeId = $"Range{i}", Creator = $"Creator{i}", Position = $"Position{i}", Value = $"Value{i}", Status = SourcePointStatus.Created, Created = DateTime.UtcNow }; dbContext.SourcePoints.Add(sourcePoints[i]); destinationCatalog[i] = new DestinationCatalog() { Name = $"https://cand3.onmicrosoft.com/test/DestinationCatalog{i}.docx" }; dbContext.DestinationCatalogs.Add(destinationCatalog[i]); destinationCatalog[i].DestinationPoints.Add(new DestinationPoint() { Catalog = destinationCatalog[i], RangeId = $"Range{i}", Creator = $"Creator{i}", Created = DateTime.UtcNow, ReferencedSourcePoint = sourcePoints[i] }); } dbContext.SaveChanges(); }