public List<string> GetProducts()
 {
     using (NorthwindEntities context = new NorthwindEntities())
     {
         var query = from product in context.Products
                     select product.ProductName;
         var products = query.ToList();
         return products;
     }
 }
        public List<string> GetProducts()
        {
            List<string> products = null;

            DataCache dataCache = null;
            if (this.enableCache)
            {
                try
                {
                    dataCache = cacheFactory.GetDefaultCache();
                    products = dataCache.Get("products") as List<string>;
                    if (products != null)
                    {
                        products[0] = "(from cache)";
                        return products;
                    }
                }
                catch (DataCacheException ex)
                {
                    if (ex.ErrorCode != DataCacheErrorCode.RetryLater)
                    {
                        throw;
                    }

                    // ignore temporary failures
                }
            }

            NorthwindEntities context = new NorthwindEntities();

            try
            {
                var query = from product in context.Products
                            select product.ProductName;
                products = query.ToList();
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }

            products.Insert(0, "(from data source)");

            if (this.enableCache && dataCache != null)
            {
                dataCache.Add("products", products, TimeSpan.FromSeconds(30));
            }

            return products;
        }
        public List<string> GetProducts()
        {
            List<string> products = null;

            NorthwindEntities context = new NorthwindEntities();

            try
            {
                var query = from product in context.Products
                            select product.ProductName;
                products = query.ToList();
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }

            return products;
        }