linq2sql: singleton or using, best practices
        Posted  
        
            by zerkms
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by zerkms
        
        
        
        Published on 2010-04-14T23:22:38Z
        Indexed on 
            2010/04/14
            23:23 UTC
        
        
        Read the original article
        Hit count: 475
        
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?
© Stack Overflow or respective owner