C# – Sub Sonic not closing connections

csubsonicsubsonic3

I'm using Linq from SubSonic 3 like this:

for(int x; x < 100; x++) {
   var v = (from c in db.categories
            where c.parent == 10
            select c);

   if (v.Count() > 0) return null;

   category[] c = v.ToArray();
}

for some reason SubSonic is not closing the connections…so after a few runs of the above loop I run out of SQL connections in the pool or MySQL just refuses to allow more connections…I've tried this both with SS 3.0.3 and with SVN, and I keep getting these errors.

What should I be doing to close out the connections after I get a set of results?

Thanks

Best Answer

The problem - believe it or not - isn't SubSonic. It's the $*$&$ MySQL driver. We explicitly close off the connection when you do queries like this, but I've seen the MySQL driver completely ignore the closure in favor of some really, really lame attempts at optimization.

I don't know what to tell you here - I'm very sorry to say.