Example 1, the following insert results in 2 batches regardless of your configuration:
INSERT INTO <b>entitytable1</b> (someInt) VALUES (1)
INSERT INTO <b>entitytable2</b> (someInt) VALUES (3)
-- Notice tables are <b>different</b>
-- Results in <b>2</b> round trips to the db
-- C# code that can generate such statements:
session.Save(typeof(entitytable<b>1</b>), new entitytable<b>1</b>{someInt = 1})
session.Save(typeof(entitytable<b>2</b>), new entitytable<b>2</b>{someInt = 3})
transction.Commit();
However, in example 2, below, the inserts result in 1 batch:
INSERT INTO <b>entitytable1</b> (someInt) VALUES (1)
INSERT INTO <b>entitytable1</b> (someInt) VALUES (3)
-- Notice tables are the <b>same</b>
-- Results in <b>1</b> round trip to the db
-- C# code that can generate such statements:
session.Save(typeof(entitytable<b>1</b>), new entitytable<b>1</b>{someInt = 1})
session.Save(typeof(entitytable<b>1</b>), new entitytable<b>1</b>{someInt = 3})
transction.Commit();
Is it possible to get example 1 to work as 2, that is, to send different inserts batched together to the db (e.g. 1 roundtrip)?
Batching definition, for the few: To send multiple statements/inserts grouped together, up to Ado_Batch_size, to the database in one round trip.
The sql shown above is generated by Nhibernate of course!. It is what you would see on NHProfiler.
Version: Nhibernate 3.2