public static SingletonProduct SetInstance() { // Uses lazy initialization. // Note: this is not thread safe. _instance = null; return(_instance); }
public static SingletonProduct Instance() { // Uses lazy initialization. // Note: this is not thread safe. if (_instance == null) { _instance = new SingletonProduct(); using (SSLsEntities db = new SSLsEntities()) { List <Products> prod = db.Products .Include("CostProductChangeLog") .Include("Vendor") .Include("ProductVatType") //.Include("ProductGroups") .Include("ProductDetails") .Where(w => w.Enable == true) .ToList(); _instance.Products = prod; List <ProductDetails> data = db.ProductDetails .Include("ProductUnit") //.Include("Products.CostType") .Include("Products.Supplier") .Include("Products.ProductVatType") .Include("SellPriceChangeLog") .Include("Products.CostProductChangeLog") .Include("Products.ProductBrands") .Where(w => w.Enable == true) .ToList(); _instance.ProductDetails = data; } } return(_instance); }