Is connection pooling working correctly in Subsonic?

为君一笑 提交于 2019-12-02 04:25:00

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.

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

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

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());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!