Jump to content
  • Advertisement
Sign in to follow this  
moeen k

read records from database with index using entity framework

This topic is 1121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi. im working on a asp webform project. i want to let user see the records like bellow;

<% shop.Models.ShopDataBaseEntities1 sdb = new shop.Models.ShopDataBaseEntities1();
       var query = sdb.customer; %>
    <table class="table table-hover">
        <%foreach (var q in query){ %>
        <tr><td><%=q.cellphone %></td><td><%=q.telephone %></td><td><%=q.customerAddress %></td><td><%=q.customerZipCode %></td><td><%=q.customerFamily  %></td><td><%=q.customerName %></td><td><%=q.customerID %></td></tr>
        <%} %>

i want to make it to show for example 10 records every page. so the structure that comes to my mind that if my queried records had indexes so i could send the index of records i have shown to next page as url parameter to show the rest of records but the query object hopefully has no index parameter or any int order value.

maybe im doing the job wrong and there is other way to do the job. thanks for your help.

Share this post

Link to post
Share on other sites
As fastcall22 said.

More precisely you can apply paging using "skip take". For example:

// things are of type DbSet

var pageSize = 10;
var page = 2; // passed in from view

var pagedResult = things.AsQueryable().Where(thing => thing.IsAccesible).Skip((page - 1) * pageSize).Take(pageSize).ToArray();

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!