简体   繁体   中英

get list of students on the bais Status value

I have to retrieve the list of students on the basis of value of Status field in Index view.

public ActionResult Index()
        {
            List<School> schools = schoolRepo.Collection().ToList();
            return View(schools);
        }
    

Here all the students are retrieved irrespective of Status value. But I want to show only those students whose Status value !=0 . How can I do this?

You can use lambda expression to filter your results:

List<School> schools = schoolRepo.Where(c => c.Status != 0).ToList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM