The Entity Framework background uses paging to retrieve data and use the AspNetPager Control

Source: Internet
Author: User

This article is a note on the use of the AspNetPager control!

For the AspNetPager control, you can view the Yang Tao homepage. This is an open custom ASP. the. NET Control supports various custom data paging methods, which are easy to use and powerful. You can use this control during website development to save a lot of unnecessary trouble.

Download this page: AspNetPager745DLL.zip

Next, let's take a look at how to pass the paging data to the control through Entity Framework on the page to implement real paging.

Page front-end code:

'Title = ''' target = "_ self"> 'target = "_ self"> no related content!

Page background code:

  Page_Load( (! ( context = = context.infolist.Where(n => n.delstate !=   BindData( pageSize,  ( context =  infoList =  info  info.delstate !=                          =====  AspNetPager1_PageChanged(

Easy to use! First, you need to tell AspNetPager how many records the data to be bound to, and then retrieve the paging data through the AspNetPager_PageChanged event. AspNetPager can customize different paging methods, or pass paging parameters through URLs. For details about how to use it, refer to the help documentation on Yang Tao's homepage. The following code shows how to get Entity Framework to return the paging query result.

                                       IQueryable<T> ToPagedQuery<T>( IQueryable<T> query,  pageSize,  query.Skip(pageSize * (pageNumber -                                      IEnumerable<T> ToPagedQuery<T>( IEnumerable<T> query,  pageSize,  query.Skip(pageSize * (pageNumber - 

It is also very simple, that is, the Skip () method and the Take () method are used to obtain the data after pagination. Entity Framework knows how to obtain the correct data records from the database. The IQueryableExtensions class in the code above contains two methods: IQueryable generic extension methods and IEnumable generic extension methods.

Then, you can enjoy powerful data paging on the page!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.