Пример #1
0
 public List <UploadedImage> GetBySubcategory(int subcategoryId)
 {
     using (var context = new ImagesDataContext(_connectionString))
     {
         return(context.UploadedImages.Where(i => i.SubcategoryId == subcategoryId).ToList());
     }
 }
Пример #2
0
 public void AddSubcategory(Subcategory subcategory)
 {
     using (var context = new ImagesDataContext(_connectionString))
     {
         context.Subcategories.Add(subcategory);
         context.SaveChanges();
     }
 }
Пример #3
0
 public void AddImage(UploadedImage image)
 {
     using (var context = new ImagesDataContext(_connectionString))
     {
         context.UploadedImages.Add(image);
         context.SaveChanges();
     }
 }
Пример #4
0
 public List <UploadedImage> GetByCategory(int categoryId)
 {
     using (var context = new ImagesDataContext(_connectionString))
     {
         return(context.UploadedImages
                .Include(u => u.Subcategory)
                .Where(i => i.Subcategory.Category.Id == categoryId)
                .ToList());
     }
 }
Пример #5
0
        public List <Category> GetCategories(bool includeSubcategories)
        {
            using (var context = new ImagesDataContext(_connectionString))
            {
                IQueryable <Category> query = context.Categories;
                if (includeSubcategories)
                {
                    query = query.Include(c => c.Subcategories);
                }

                return(query.ToList());
            }
        }