コード例 #1
0
 public byte[] GetProductImage(int productId)
 {
     AdventureWorksDataContext db = new AdventureWorksDataContext();
     return (from p in db.Products
             where p.ProductID == productId
             select p.ThumbNailPhoto).SingleOrDefault<Binary>().ToArray();
 }
コード例 #2
0
 public int GetProductsCountByCategories(int[] categoryIds)
 {
     AdventureWorksDataContext db = new AdventureWorksDataContext();
     return (from p in db.Products
             where categoryIds.Contains(p.ProductCategoryID.Value)
             select p).Count();
 }
コード例 #3
0
 public ProductCategory[] GetCategories()
 {
     AdventureWorksDataContext db = new AdventureWorksDataContext();
     return (from c in db.ProductCategories
             where c.ParentProductCategoryID == null
             select c).ToArray();
 }
コード例 #4
0
        public ProductCategory[] GetSubcategories(string category)
        {
            AdventureWorksDataContext db = new AdventureWorksDataContext();

            return (from c in db.ProductCategories
                    where c.ParentProductCategoryID == GetCategoryId(category)
                    select c).ToArray();
        }
コード例 #5
0
        private int GetCategoryId(string category)
        {
            AdventureWorksDataContext db = new AdventureWorksDataContext();
            var result = (from c in db.ProductCategories
                          where c.Name == category
                          select c.ProductCategoryID);

            return (result.Count<int>() > 0) ? result.First<int>() : -1;
        }
コード例 #6
0
 public Product[] GetProductsByCategories(int[] categoryIds, int page, int pageSize)
 {
     int startRowIndex = (page-1) * pageSize;
     int maximumRows = pageSize;
     AdventureWorksDataContext db = new AdventureWorksDataContext();
     return (from p in db.Products
             where categoryIds.Contains(p.ProductCategoryID.Value)
             orderby p.Name ascending
             select p)
             .Skip(startRowIndex)
             .Take(maximumRows)
             .ToArray();
 }
コード例 #7
0
 public Product GetProduct(int productId)
 {
     AdventureWorksDataContext db = new AdventureWorksDataContext();
     return db.Products.Where(p => p.ProductID == productId).SingleOrDefault();
 }
コード例 #8
0
 public int GetProductsCount()
 {
     AdventureWorksDataContext db = new AdventureWorksDataContext();
     return db.Products.Count();
 }