views:

533

answers:

4

I am getting reports that connection pooling is not working in the Subsonic orm when used with sql server on a remote machine. I'm not sure how they are monitoring this, maybe with the profiler.

Subsonic opens late, closes early as you are supposed to do in an orm layer, but is there any problem with the implementation that would cause too many connections?

+6  A: 

There is a way for a connection to remain open when using SubSonic. Many people assume that when you load a collection the reader will be closed for you - but it's not (a class should never act on another class without permission). There is a method called "LoadAndCloseReader()" just for this reason.

If you could find out more that would be great.

Rob Conery
+1  A: 

Does this mean that SubSonic's connections are persistent by default?

Tal Even-Tov
A: 

This is something i only recently discovered myself after having similar issues.

As Rob said it should not be used like this:

MyTableCollection objCol = new MyTableCollection().Load();

it should be used like:

MyTableCollection objCol = new MyTableCollection();
objCol.LoadAndCloseReader(MyTable.FetchAll());
Doug
Maybe this:MyTableCollection objCol = new MyTableCollection();objCol.LoadAndCloseReader(MyTable.FetchAll());I don't do this anywhere. I have about 40 lines to change. There is no documentation for LoadAndCloseReader. Look at http://subsonicproject.com/docs/Main_Page, it's not to be found. I haven't worked with subsonic in months.
P a u l
+1  A: 

I'm not sure about the earlier versions, but in 2.1, AbstractList.Load() already uses LoadAndCloseReader(rdr) wrapped in a using statement.

sjlewis