public int Count(RoleSearchEntity RoleSearchEntity) { if (RoleSearchEntity == null) { RoleSearchEntity = new RoleSearchEntity(); } IQueryable <Role> Roles = context.Roles; Apply(Roles, RoleSearchEntity); return(Roles.Count()); }
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()); }
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); }