Last post Dec 24, 2019 02:36 AM by Yang Shen
Dec 23, 2019 12:18 PM|maddy1460|LINK
I need help,
Here the problem is that I want to make an API for the app, during scroll I can search the data. In the below code, I am able to do Infinite scroll but not sure how to give search functionality. For example, I have a scroll 3 pages (1 page have 10 records)
and during that time I want to search string like "David" so it will give search string within 30 records
public dynamic GetAllUsersList(int Count, int UserId)
using (LystenEntities db = new LystenEntities())
OnlineUserViewModel uv = new OnlineUserViewModel();
uv.TotalCount = db.User_Master.Where(x => x.IsActive == true).Where(x => x.RoleId != 1 && x.Id != UserId).ToList().Count();
int skip = 10 * Count;
string baseURL = HttpContext.Current.Request.Url.Authority;
baseURL += (WebConfigurationManager.AppSettings["userimagepath"]).Replace("~", "");
db.User_Master.Where(x => x.RoleId != 1 && x.Id != UserId && x.IsActive == true).Select(x => new userdetail()
Id = x.Id,
Email = x.Email,
Displayname = x.FullName == null ? "" : x.FullName,
Image = (x.Image == null) ? "" : x.Image == "" ? "" : (baseURL + x.Image)
}).OrderBy(x => x.Displayname).Skip(skip).Take(10).ToList();
" record at 3-page index</div>
Dec 24, 2019 02:36 AM|Yang Shen|LINK
I am able to do Infinite scroll but not sure how to give search functionality.
The requirement is not clear enough, do you have problem in how to select string LIKE "David" in Linq? If so, please check LINQ to SQL: How to write a 'Like' select?.
Call this select method through Ajax in your Infinite scroll event.