Beispiel #1
0
        public int Count(RoleSearchEntity RoleSearchEntity)
        {
            if (RoleSearchEntity == null)
            {
                RoleSearchEntity = new RoleSearchEntity();
            }
            IQueryable <Role> Roles = context.Roles;

            Apply(Roles, RoleSearchEntity);
            return(Roles.Count());
        }
Beispiel #2
0
        public List <Role> List(RoleSearchEntity RoleSearchEntity)
        {
            if (RoleSearchEntity == null)
            {
                RoleSearchEntity = new RoleSearchEntity();
            }
            IQueryable <Role> Roles = context.Roles;

            Roles = Apply(Roles, RoleSearchEntity);
            Roles = SkipAndTake(Roles, RoleSearchEntity);
            return(Roles.ToList());
        }
Beispiel #3
0
 private IQueryable <Role> Apply(IQueryable <Role> Roles, RoleSearchEntity RoleSearchEntity)
 {
     if (RoleSearchEntity.Id.HasValue)
     {
         Roles = Roles.Where(t => t.Id == RoleSearchEntity.Id.Value);
     }
     if (!string.IsNullOrEmpty(RoleSearchEntity.Name))
     {
         Roles = Roles.Where(t => t.Name.ToLower().Contains(RoleSearchEntity.Name.ToLower()));
     }
     if (!string.IsNullOrEmpty(RoleSearchEntity.Code))
     {
         Roles = Roles.Where(t => t.Code.ToLower().Contains(RoleSearchEntity.Code.ToLower()));
     }
     return(Roles);
 }