コード例 #1
0
        public ActionResult Index(FormCollection form, CategorySearchModel categorySearchModel)
        {
            var list = from category in db.Categories.ToList()
                       where (
                            (!String.IsNullOrEmpty(categorySearchModel.CategoryName) ?
                                category.CategoryName.Contains(categorySearchModel.CategoryName,
                                    StringComparison.OrdinalIgnoreCase) : true
                            ) &&
                            ((categorySearchModel.Id != default(int)) ?
                                categorySearchModel.Id == category.Id : true
                            )
                       )
                       select new Category
                       {
                           Id = category.Id,
                           CategoryName = category.CategoryName,
                           CategoryDescription = category.CategoryDescription,
                           CategoryStatus = category.CategoryStatus,
                           CreateDate = category.CreateDate,
                           UpdateDate = category.UpdateDate,
                       };

            categorySearchModel.Category = list;
            categorySearchModel.Queryables = GetQueryables();

            return View(categorySearchModel);
        }
コード例 #2
0
        public ActionResult Index()
        {
            CategorySearchModel categorySearchModel = new CategorySearchModel();

            var list = from category in db.Categories.ToList()
                       select new Category
                       {
                           Id = category.Id,
                           CategoryName = category.CategoryName,
                           CategoryDescription = category.CategoryDescription,
                           CategoryStatus = category.CategoryStatus,
                           CreateDate = category.CreateDate,
                           UpdateDate = category.UpdateDate,
                       };

            categorySearchModel.Category = list;
            categorySearchModel.Queryables = GetQueryables();
            categorySearchModel.Id = default(int);

            return View(categorySearchModel);
        }