score:1
Accepted answer
using (var context = new mjbweblogcontext())
{
return context.posts.where(post => post.published)
.orderbydescending(p => p.postedon)
.skip(pageno * pagesize)
.take(pagesize)
.tolist();
}
score:0
list<post> iblogrepository.postsforlist(int pageno, int pagesize)
{
using (var context = new mjbweblogcontext())
{
return context.posts.include("category").where(a => a.published == true)
.orderbydescending(p => p.postedon)
.skip(pageno * pagesize)
.take(pagesize)
.tolist();
}
}
Source: stackoverflow.com
Related Query
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- how to fetch data from Func using generic list and linq
- Get data from database using linq query and display it in dynamically generated labels in repeater
- how to write Like Query for search Username from database in LINQ and ADO.NET
- How to retrieve data for two different portions of a single web page using LINQ from the same database table?
- How to query database using LINQ to bring data from database based on array of months in ASP.Net MVC 5?
- How to query many-to-many relationship with 'AND' condition using LINQ and Entity Framework
- how to convert Database Hierarchical Data to XML using ASP.net 3.5 and LINQ
- Is a full list returned first and then filtered when using linq to sql to filter data from a database or just the filtered list?
- Pull data from multiple tables in one SQL query using LINQ and Entity Framework (Core)
- Get Min and Max for items from database using Linq
- How to write LINQ query for getting object from another object using C#?
- How to write a generic LINQ query for filtering of data based on first name middle name and last name
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How to return values from a LINQ query and display them in a table using C#, ASP.NET MVC and Entity Framework
- How to get elements from List<> using Linq and Dictionary in query C#?
- LINQ - database query using "into", how do I reference data prior to "into" in the select clause?
- how to fetch multiple table data in a single linq query and bind it to a autocomplete search model
- How to dynamically query the database using LINQ and a variable?
- How to check linq query result against Sql Server Database for data already exist or not?
- Linq query to get data from Database using group by clause
- How to show 2nd row on Data in Next Button Click in C# and XML database using LINQ
- Using LINQ and EF, how to remove values from database where not in list of items
- How do I group items from a collection using LINQ and return the shaped data according the collection type
- Using LINQ and Reflection: How to query for all Classes with [Authorize] Attribute in my Assembly?
- Get all data from database for Administrator role but not for other roles, using same query
- Searching for multiple strings using single database query with entity framework and LINQ
- How to design nested query for fetching data from tables of MS SQL using Entity Framework?
- How to fetch value against list of strings from xml using linq and xpath?
- How to get a strongly typed linq query of a data table and database
More Query from same tag
- C# Compare values in SPItemList and only retrieve matching ones
- LINQ to XML type declaration
- Appending dynamic where statements in LINQ to Entities but as an OR operator instead of AND
- Using Group By in more then a column in a DataTable
- LINQ Query: Determining if object in one list exists in another based on key
- LINQ to SQL: Select count rows for each date in a provided range?
- Search multiple tables with no relation by special value with one query using linq to entity
- Using a database with Silverlight?
- Distinct between two queries
- Getting the Parent object in nested XML to Linq
- I have an IQueryable with WHERE IN (ids). Can ToList() return the same order as ids?
- Convert object to a queryable
- Sort List<T> with an array
- Perform a LINQ query without using NotMapped properties in EF
- updating and exporting an array of id's via entityframework
- LINQ, Join, GroupBy and Count
- Linq query to update values based on another column
- Linq to sql query for check the usernames exists in table?
- Linq to list, then to DataGrid
- line number while querying with linq
- Get data from with dynamic where argument
- Preserving Order In Sequence of Choices (LINQ To XSD)
- extract distinct list of number from a list of strings in C#
- How do I query identity data efficiently in ASP.Net Core?
- c# how to compare and replace into a list<class> from another
- Why doesn't XElement have a GetAttributeValue method?
- How to get value from nested KeyValuePair from IMongoCollection
- Merging two tables and concatenating the values using linq
- A List of Field Names as a String Array - LINQ Expressions
- Custom sort logic in OrderBy using LINQ