Vendor.UseBulkInsert[db.Shippers]
= true;
db.Shippers.Add(new Shippers(-1, "UPS", "800-800-8888"));
db.Shippers.Add(new Shippers(-1, "Fedex", "900-900-9999"));
db.SubmitChanges();
Limitations:
ShipperID field (the IDENTITY column) is never updated on the client, because the communication is one-way
Additional permissions are required for bulk insert (vs. regular insert)
SqlBulkCopyOptions.TableLock flag is always on
internally, we create a DataTable (containing all rows) to send - this costs extra memory. See Azamsharp, below, for alternative.
INSERT
INTO Shippers (ShipperName,PhoneNumber) VALUES
('UPS',
'800-800-8888'),
('Fedex',
'900-900-9999'),
...
Vendor.UseBulkInsert[db.Shippers]
= 3; //specify bulk insert, three
rows at a time
db.Shippers.Add(new Shippers(-1, "UPS", "800-800-8888"));
db.Shippers.Add(new Shippers(-1, "Fedex", "900-900-9999"));
db.SubmitChanges();
Please have a look at unit test WriteTest_BulkInsert.
The PostgreSQL command is called COPY. This is currently not exposed from DB LINQ.
Please can someone research if this can be used with anything else besides local
files?