Пример #1
0
        public IActionResult GetRoleDataList(string name)
        {
            using (this.DbContext)
            {
                IQueryable <Role> query = this.DbContext.Role.AsNoTracking();
                query = query.OrderByDescending(o => o.CreateTime);
                query = query.AddBooleanFilter(o => o.IsForbidden, false);
                query = query.AddBooleanFilter(o => o.IsEnable, true);
                query = query.AddStringContainsFilter(o => o.Name, name);
                Pager pager = Pager.CreateDefaultInstance();

                return(this.StandardSearchResponse(query, pager, RoleModel.Convert));
            }
        }
Пример #2
0
        public IActionResult Search(PermissionPostModel model)
        {
            using (this.DbContext)
            {
                IQueryable <Permission> query = this.DbContext.Permission.AsNoTracking();
                query = query.AddBooleanFilter(o => o.IsEnable, model.IsEnable);
                query = query.AddStringContainsFilter(o => o.ActionCode, model.ActionCode);

                return(this.StandardResponse(query, model));
            }
        }
Пример #3
0
        public void TestAddBooleanFilter()
        {
            using (var context = new CoreContext())
            {
                IQueryable <User> query = context.User;
                query = query.AddBooleanFilter(o => o.IsEnable, false);
                var a = context.User.Where(o => o.IsEnable == false).Expression.ToString();
                var b = query.Expression.ToString();

                Assert.AreEqual(a, b, UnitTestResource.TestAddBooleanFilter);
            }
        }