ExecuteSprocAccessor is slow

Topics: Data Access Application Block
Sep 2, 2010 at 3:52 PM
Edited Sep 2, 2010 at 4:04 PM


I have used older versions of entlib and have used ExecuteReader and then mapped the properties to my objects by myself.

In entlib 5.0 there is ExecuteSprocAccessor wich makes life a bit easier, and auto-maps the properties. The problem for me is that it is 5 times slower.

The old ExecuteReader (returning only 1 row) takes <1ms to do everythin. The new ExecuteSprocAccessor takes 4-5ms.

Is this what I should expect?


var db = EnterpriseLibraryContainer.Current.GetInstance<Database>("connectionstring") as SqlDatabase;
var myObject = db.ExecuteSprocAccessor<MyObject>("mySP", new object[] { param1, param2 }).SingleOrDefault();

Sep 3, 2010 at 12:11 AM

The accessor has to do a bunch of work to generate the output mapper it uses. If you recreate the accessor every time, you end up paying that construction cost every time. Can you create the accessor once up front and reuse it instead?


Sep 3, 2010 at 6:43 AM

Thank you. It worked perfect.

Sep 18, 2010 at 1:58 PM

Does this mean that using the ExecuteSprocAccessor is not appropriate for disconnected (WCF) applications due to the construction cost of the accessor?