HOW TO SHOW FIRST FIVE RECORDS IN ENTITY FRAMEWORK

Sachin Singh

Total Post:26

Points:182
Posted by  Sachin Singh
 592  View(s)
Ratings:
Rate this:
Hi All,

I want to display first five records using entity frameworks using ASP.NET MVC.
My code  is below :


I want to find first 5 records. Please can anyone help.
Thank you.
  1. Anupam Mishra

    Post:135

    Points:949
    Re: How to show first five records in Entity Framework

    Hi Sachin

    This is a very basic approach to finding:

     var screens = db.AssignedScreen.Take(5).ToList();
    we have also IEnumerable Interface we have also use like this:
     
     var screens= db.AssignedScreen.ToList().Take(5);  
    or, we have also sort our element

     var screens =  db.AssignedScreen.OrderByDescending(c => c.arg**).Take(5).ToList();
    ** arg is a argument

      Modified On Mar-22-2016 12:44:55 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!