public void 新增大量資料() { var employees = new List <Employee>(); for (var i = 0; i < 10000; i++) { employees.Add(new Employee { Id = Guid.NewGuid(), Name = Name.FullName(), Age = RandomNumber.Next(1, 120) }); } using (var db = new LabEmployee2DB(ConnectionName)) { db.BulkCopy(employees); } }
public void 新增大量資料() { var employees = new List <Employee>(); for (var i = 0; i < 10000; i++) { employees.Add(new Employee { Id = Guid.NewGuid(), Name = Name.FullName(), Age = RandomNumber.Next(1, 120) }); } using (var db = new LabEmployee2DB(ConnectionName)) { var bulkCopyOptions = new BulkCopyOptions { BulkCopyType = BulkCopyType.ProviderSpecific, UseInternalTransaction = true }; db.BulkCopy(bulkCopyOptions, employees); } }