BulkInsert sample

Sep 8, 2015 at 12:48 AM
Hello,

is there any example of use for BulkInsert method?

TIA
Coordinator
Sep 8, 2015 at 2:53 PM
First, let's be clear on what BulkInsert does. It's purely a convenience method that is a simple extension method. It takes in an array of items, iterates across them and calls Insert for each item. It's not equivalent to anything like SQL Server's BCP, and doesn't give any performance gains.

Usage is really simple. Let's say we have an Entity called Thing. You can insert a set of them like this:
IEnumerable<Thing> things = GetThings();
myDataStore.BulkInsert(things);
Functionally, this is identical to doing this:
IEnumerable<Thing> things = GetThings();
foreach(var thing in things)
{
    myDataStore.Insert(thing);
}
Sep 9, 2015 at 4:25 PM
Thanks ctacke,

What I was looking for was performance gains, it became really slow inserting many records.

I found the ORM_CreateProxy approach and now it flies!
Sep 9, 2015 at 7:51 PM
Edited Sep 9, 2015 at 7:52 PM
For the record, the key point to improve speed, besides ORM_CreateProxy, is the UseCommandCache property in DataStore:
  store.ConnectionBehavior = ConnectionBehavior.Persistent;
  store.UseCommandCache = true;