score:15
Accepted answer
You can use the Take() method
List<aspnet_News> allNews = context.aspnet_News.OrderByDescending(i => i.NewsId)
.Take(3) // Takes the first 3 items
.ToList();
It'll also handle the case where the list contains less than 3 items and take them only.
score:2
Use method Take() and if you need, you can use Skip() as well.
Source: stackoverflow.com
Related Articles
- Entity Framework Code First Select Item Based on Relationship
- How to select first list item to null using Linq
- Linq code to select one item
- Select single item from a list
- LINQ: Select all from each group except the first item
- LINQ select List where sub-list contains item from another list
- Get first item in list from linq query
- Using Linq select an item outside an List
- How do I select everything in a list after the first occurence of?
- How can select first 3 item of list<>
- Move First 10 List Items to Another Item List
- Sort collection by first item of sub list in Entity Framework
- How to select objects from a list that has a property that matches an item in another list?
- LINQ, select with only the first element of child item
- Select items from a list after the first occurrence of a character
- LINQ select where item is not in list
- Linq, select List Item where column is the max value
- Return first item in list if FirstOrDefault returns null
- Select last wrong item from the list
- How to select multiple item from list with related condition
- Select first word of list of strings and concat last char of the rest of items on list in linq
- LINQ select from first list
- Code First EF: While searching database table is it possible to retrieve list of items it has in DataModel?
- select from list which has same code
- LINQ to retrieve first matching item, or a blank value for each item in a list
- How to loop through a child list of objects in Entity Framework 4.1 code first
- Check for next highest / lowest value in list and select that item
- Linq select where entity property value matches value of property of any item in another List
- Code First Entity Framework, select ViewModel - constructor with parameter
- Select on empty list's group item gives non-empty list
- c# linq group by - Access other properties inside select new
- Optimize LINQ to SQL statement that has foreign key access
- What data structure should I use to accept any type of object and allow grouping based on its different properties?
- Get latest previous year if possible
- Obtaining the outcome of a LINQ Select Query and assigning it to a string
- Optimized C# Code. Want to use better technique without nested loops
- How can I implement it by Linq?
- LINQ Sort DataTable based on 2 columns
- How to add a condition inside or after .Select() using Linq EF
- Sort by Count Occurrences of a Word in list rows linq
- selecting date where date can be null
- Operand data type time is invalid for add operator
- How would I write this dynamic linq query?
- Association on LINQ on Entity Framework
- How to calculate active and inactive statistics without loading all data of table?
- LINQ Between Operator
- Multiple levels with theninclude not returning all rows unless I query the detail
- Check a list of DTOs using linq to see if all values that exclude a particular value all equal the same thing
- Details' View with related data via LINQ using a custom model
- VB.NET - Change LINQ query to DataSet query