linq2sql: singleton or using, best practices
- by zerkms
what is the preferred practice when linq2sql using (in asp.net mvc applications): to create "singleton" for DataContext like:
partial class db
{
static db _db = new db(global::data.Properties.Settings.Default.nanocrmConnectionString, new AttributeMappingSource());
public static db GetInstance()
{
return _db;
}
}
or to retrieve new instance when it needed within using:
using (db _db = new db())
{
...
}
the usage of using brings some limitations on code. so I prefer to use singleton one. is it weird practice?