.NET RIA Services Introduction

When you’re working with Silveright one of your main challenges is to get the data you want from the database
through multiple tiers and pass it to your Silverlight client using some kind of a WebService. You’d want full CRUD support no matter what architecture pattern you are are using and you’ll need client side change tracking as well. You’d welcome features as code sharing, validation, authentication and authorization support on service operations and of course all these should be enabled automatically by a code generation process.

This is the first one of a series of screencasts in which I’ll try to introduce you to .NET RIA Services which aims to solve the issues mentioned above.

The first video provides a glimpse into the basics how .NET RIA Services works. Hope you’ll enjoy it!

You can download the demo project from here:

RIA Services Nuggets – DataPager Issues

Friday I was really brave. (or just crazy) I decided to use Entity Framework as a data source (for the first time) and tried to show the datapaging feature with .NET RIA Services. (Rule No.1: Don’t ever try a demo you’ve never tried before. :)) It has such a cool lazy loading feature. My xaml looked like this:


Then it hit me in the face. 20 items were loaded just fine but from 20 to I don’t know how many it just wouldn’t work. The data never arrived. I was quite surprised. Finally I decided to give it up since it’s probably a bug and RIA is just CTP. Then I came home and tried to reproduce the issue and I succeeded! 🙂 I had to face the fact: IT WAS NOT WORKING! Come ooooon! Such a basic thing and it’s bugy…. It made me really upset. 🙂

Then I got into it a little deeper and tried to debug the issue. I found an interesting error message:

“The method ‘Skip’ is only supported for sorted input in LINQ to Entities. The method ‘OrderBy’ must be called before the method ‘Skip’.”

Well yeah… that was it. The paging functionality is implemented with the use of Take and Skip methods. However in Entity Framework you can call these methods only on sorted collections and by deafult ObjectQueries are not sorted unless you call OrderBy() on them. So I had to modify the GetCustomer operation in my DomainService like this:


Now it’s working just fine. (SortDescriptors defined on the DomainDataSource would have been just fine as well)

But why isn’t this documented anywhere? Or did I missed something?