コード例 #1
0
ファイル: Site.Master.cs プロジェクト: moseskereya/Shop-App
        public IQueryable <Category> GetCategories()
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Category> query = _db.categories;

            return(query);
        }
コード例 #2
0
 public void Dispose()
 {
     if (_db != null)
     {
         _db.Dispose();
         _db = null;
     }
 }
コード例 #3
0
        public IQueryable <Product> GetProducts([QueryString("id")] int?categoryId)
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Product> query = _db.products;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(p => p.CategoryID == categoryId);
            }
            return(query);
        }
コード例 #4
0
        public IQueryable <Product> GetProducts(
            [QueryString("id")] int?categoryId,
            [RouteData] string categoryName)
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Product> query = _db.Products;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(p => p.CategoryID == categoryId);
            }

            if (!String.IsNullOrEmpty(categoryName))
            {
                query = query.Where(p =>
                                    String.Compare(p.Category.CategoryName,
                                                   categoryName) == 0);
            }
            return(query);
        }
コード例 #5
0
        public IQueryable <Product> GetProduct(
            [QueryString("ProductID")] int?productId,
            [RouteData] string productName)
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Product> query = _db.Products;

            if (productId.HasValue && productId > 0)
            {
                query = query.Where(p => p.ProductID == productId);
            }
            else if (!String.IsNullOrEmpty(productName))
            {
                query = query.Where(p =>
                                    String.Compare(p.ProductName, productName) == 0);
            }
            else
            {
                query = null;
            }
            return(query);
        }