In my project I have about 10 DataContext. My question is whether I have to use global instance or create each single instance of datacontext in a method. Which of the method (from method1 and method2) is better from design point of view.
public class Database
{
USDataContext USDB = new USCDataContext();
//Method 1 Global instance
public void update US_CountryTable()
{
USDB.updateCountryTable();
}
// Method 2 individual instance
public void Update CountryTable(string country)
{
switch (country)
{
case:GB
GBDataContext GBDB = new GBCDataContext();
GBDB.updateCountryTable();
// Some suggest this may be helpful
// using (GBDataContext dbContext = new GBDataContext ())
// { GBDB.updateCountryTable();
// }
break;
case: US
USDataContext USDB = new USCDataContext();
USDB.updateCountryTable();
break;
}
}
}
Thanks