Static DB Provider in ASP.NET MVC Causing Memory Leak
- by user364685
Hi, I have got an app I'm going to write in ASP.NET MVC and I want to create a DatabaseFactory object something like this:-
public class DatabaseFactory
{
private string dbConn get { return <gets from config file>; }
public IDatabaseTableObject GetDatabaseTable()
{
IDatabaseTableObject databaseTableObject = new SQLDatabaseObject(dbConn);
return databaseTableObject;
}
}
and this works fine, but I obviously have to instantiate the DatabaseFactory in every controller that needs it. If I made this static, so I could, in theory just call DatabaseFactory.GetDatabaseTable() it would cause a memory leak, wouldn't it?