|
using ASPNET_MVC_Store.Model.NorthwindDataSetTableAdapters;
namespace ASPNET_MVC_Store.Model {
public partial class NorthwindDataSet
{
private static NorthwindDataSet instance;
private CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter();
private ProductsTableAdapter productsTableAdapter = new ProductsTableAdapter();
private SuppliersTableAdapter suppliersTableAdapter = new SuppliersTableAdapter();
public static NorthwindDataSet Instance
{
get
{
if (instance == null)
{
instance = new NorthwindDataSet();
instance.Init();
}
return instance;
}
}
public void Init()
{
if (IsInTestMode)
FillWithTestData();
else
FillWithRealData();
}
private void FillWithTestData()
{
instance.Categories.AddCategoriesRow("Cat 1", "Cat 1 Desc", null);
instance.Products.AddProductsRow("Pr 1", null, instance.Categories[0],
"1", 1, 1, 1, 1, false);
}
private void FillWithRealData()
{
categoriesTableAdapter.Fill(instance.Categories);
productsTableAdapter.Fill(instance.Products);
suppliersTableAdapter.Fill(instance.Suppliers);
}
private bool IsInTestMode
{
get
{
return System.Configuration.ConfigurationManager
.ConnectionStrings["NwindConnectionString"] == null;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Oleg Zhukov, born and living in Russia is Lead Engineer and Project Manager in a company which provides business software solutions. He has graduated from Moscow Institute of Physics and Technology (MIPT) (department of system programming) and has got a M.S. degree in applied physics and mathematics. His research and development work concerns architectural patterns, domain-driven development and systems analysis. Being the adherent of agile methods he applies them extensively in the projects managed by him.