How bad of a practice would it be to declare as a page-level property:
LinqMetaData _linqMetaData = new LinqMetaData(new DataAccessAdapter(false));
so at any point (or at multiple points) in the page, I can do something like:
int orderCount = this._linqMetaData.Orders.Count();
The best practice is to use something like the following to insure the adapter gets disposed after being used.
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
LinqMetaData metaData = new LinqMetaData(adapter);
}
When does the adapter get disposed of in this approach?
When it goes out of scope. i.e. when the page is disposed.
If I do not manually start a transaction with the adapter, how long is a transaction opened for something like the above count query?
No transaction is opened for the above code, only the database default implicit transaction.
Would it make a difference if i set keepConnectionOpen in the CTOR to true?
Not a recommended practice, only do this when you have multiple consecutive commands to execute.
Would it make a difference if I handled the unload / descructor of the page and did:
this._linqMetaData.Adapter.Dispose();
?
I think it won't make a difference.