CRM Development

Solutionist has designed the architecture for a new CRM system for use in the medical imaging industry.

Friday, 6 August 2010

RIA Services and ASP.NET

I've been looking at WCF RIA services for a new project - and looking at seeing if I can use the DomainService on an ASP.NET page directly.

This gets you to a half-way house situation where you have your middle-tier, but don't have to learn Silverlight just yet. It's not immediately obvious where to start, but you need to get hold of the RIA services toolkit (for SL4... I'm working with VS2010) - which then gives you a DomainDataSource available for use on .aspx pages.

So.... created my DomainService with a couple of related entities.
pulled in a couple of DomainDataSources for the master and detail queries and hooked up a grid for the master query and DetailView for the detail.

The basic concept worked fine!

But.. then I tried to enable paging and sorting in the master and detail view and got this error

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: The method ‘Skip’ is only supported for sorted input in LINQ to Entities. The method ‘OrderBy’ must be called before the method ‘Skip’.
Hmmm....

It turns out (thanks to this link) that you need to add some default ordering to your query methods in the DomainService. This enforces the ordering before any other modifier.

1 comment:

  1. Hello Yossi,

    In all fairness, if you look at the comments that are added when you first create a RIA service, you'll see the words...

    "To support paging you will need to add ordering to the 'Users' query."

    I also didn't read all that stuff, and would probably have ended up trawling the web for hours!

    AY

    ReplyDelete