DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
  • How To Check IP Addresses for Known Threats and Tor Exit Node Servers in Java
  • Observability Architecture: Financial Payments Introduction
  • VPN Architecture for Internal Networks

Trending

  • A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
  • How To Check IP Addresses for Known Threats and Tor Exit Node Servers in Java
  • Observability Architecture: Financial Payments Introduction
  • VPN Architecture for Internal Networks
  1. DZone
  2. Data Engineering
  3. Data
  4. Using Paging in WCF Data Services

Using Paging in WCF Data Services

Gil Fink user avatar by
Gil Fink
·
Jun. 23, 10 · News
Like (0)
Save
Tweet
Share
5.77K Views

Join the DZone community and get the full member experience.

Join For Free

One of the mechanisms which were provided in WCF Data Services from the start was client side paging. In the new release of WCF Data Services we also get a server side paging and this will be addressed in this post.

WCF Data Services Client Side Paging

From the early days of WCF Data Services we could achieve paging on the client side using the $top and $skip query parameters. For example the following URI for a data service will bring the 11-20 courses which were requested:

http://localhost:8322/SchoolDataService.svc/Courses?$skip=10&top=10

The problem starts when you expose resources with a lot of items.  Lets say that we have 10000 courses in our course library. The following URI will bring to the client all of them:

http://localhost:8322/SchoolDataService.svc/Courses
Running this request will decrease the amount of clients for the service since it will take ages for the query to return. So what can we do?  Use server side paging instead.

WCF Data Services Server Side Paging

So how can we limit our returning result set to the client? we can use a new feature of WCF Data Services. In order to create a server side paging behavior all we need to do is to configure the service to return some portion of data. We will use the new method of the DataServiceConfiguration class which is called SetEntitySetPageSize for each entity set or for all of them at once (using * ). The following code create server side paging for all the entity sets exposed by the data service to return only 10 items at once:


public class SchoolDataService : DataService<SchoolEntities>

{

public static void InitializeService(DataServiceConfiguration config)

{

config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);

config.SetEntitySetPageSize("*", 10);

config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;

}

}

When I use the service now with a URI to retrieve all the courses I will get only the first ten courses. Also as you can see in the figure we get a link at the bottom that leads us the next ten results:

and the link itself is written as:

http://localhost:8322/SchoolDataService.svc/Courses?$skiptoken=4041


Summary

In the new release of WCF Data Services we get a new paging feature which enable server side paging. Using this method or combining it with client side paging extend the capabilities of WCF Data Services. The use of the server side paging is very easy – just configure the service. In the post I showed an example of how you can achieve that behavior.

 

 

Windows Communication Foundation WCF Data Services Data (computing)

Published at DZone with permission of Gil Fink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
  • How To Check IP Addresses for Known Threats and Tor Exit Node Servers in Java
  • Observability Architecture: Financial Payments Introduction
  • VPN Architecture for Internal Networks

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: