There Be Dragons: Rhino.Commons.SqlCommandSet

After last night's post about the performance benefits of SqlCommandSet, I decided to give the ADO.Net team some headache, and release the results in a reusable form.

The relevant code can be found here, as part of Rhino Commons. Beside exposing the batching functionality, it is very elegant (if I say so myself) way of exposing functionality that the original author decided to mark private / internal.

I really liked the declaration of this as well:

[

ThereBeDragons("Not supported by Microsoft, but has major performance boost")]
public class SqlCommandSet : IDisposable

The usage is very simple:

SqlCommandSet commandSet = new SqlCommandSet();

commandSet.Connection = connection;

for (int i = 0; i < iterations; i++)

{

       SqlCommand cmd = CreateCommand(connection);

       commandSet.Append(cmd);

}

int totalRowCount = commandSet.ExecuteNonQuery();

As a note, I spiked a little test of adding this capability to NHibernate, and it seems to be mostly working, I got 4 (out of 694) test failing because of this. I didn't check performance yet.

Print | posted on Thursday, September 14, 2006 5:25 AM

Feedback


Gravatar

#  9/14/2006 9:36 AM Dan

Nicely done, thanks!


Gravatar

#  9/14/2006 6:43 PM Gabe

Thanks Ayende! This is awesome. It just made a huge difference to the performance of a data import tool I am creating.

Comments have been closed on this topic.