public bool Save(List <string> data) { if (data == null) { return(false); } List <Product> products = data.Select(x => new Product { Id = Guid.NewGuid(), Code = x }).ToList(); using (DemoContext context = new DemoContext()) { context.Products.DeleteFromQuery(); context.BulkInsert(products); } return(true); }
public bool Save(List <string> warehouseData) { if (warehouseData == null) { return(false); } List <Warehouse> warehouses = warehouseData.Select(x => new Warehouse { Id = Guid.NewGuid(), Code = x }).ToList(); using (DemoContext context = new DemoContext()) { context.Products.DeleteFromQuery(); context.BulkInsert(warehouses); } return(true); }
public bool Save(List <CategoryEntity> data) { if (data == null) { return(false); } List <Category> categories = data.Select(x => new Category { Id = x.Id, Code = x.Code, ParentId = x.ParentId, Path = x.CategoryPath }).ToList(); using (DemoContext context = new DemoContext()) { context.Categories.DeleteFromQuery(); context.BulkInsert(categories); } return(true); }
public bool Save(List <InventoryEntity> list) { if (list == null) { return(false); } List <Inventory> inventories = list.Select(x => new Inventory { CategoryId = x.CategoryId, ProductId = x.ProductId, WarehouseId = x.WarehouseId, Quantity = x.Quantity }).ToList(); using (var context = new DemoContext()) { context.Inventories.DeleteFromQuery(); context.BulkInsert(inventories); } return(true); }