public async Task <HttpResponseMessage> Get(HttpRequestMessage request, int id = 0, string tags = "*", string name = "*", int hospitalid = 0, int pagesize = 15, int pageindex = 1) { Expression <Func <tbDomain, bool> > filter, tagsfilter, namefilter, hospitalidfilter = null; if (id != 0) { filter = l => l.ID == id; } else { filter = l => l.IsDeleted != true; } if (tags != "*") { tagsfilter = l => l.Tags.Contains(tags); } else { tagsfilter = l => l.IsDeleted != true; } if (name != "*") { namefilter = l => l.Name.StartsWith(name); } else { namefilter = l => l.IsDeleted != true; } if (hospitalid != 0) { hospitalidfilter = l => l.HospitalId == hospitalid; } else { hospitalidfilter = l => l.IsDeleted != true; } var skipindex = pagesize * (pageindex - 1); var objs = repo.GetWithoutTracking().Where(filter).Where(namefilter).Where(tagsfilter).Where(hospitalidfilter).OrderBy(a => a.Name).Skip(skipindex).Take(pagesize).ToList(); HttpResponseMessage response = request.CreateResponse <List <tbDomain> >(HttpStatusCode.OK, objs); return(response); }