March
23
If for whatever reason you need to return a very big set of data using WCF RIA Services, you will see that, you will quickly run into major roadblocks.
The first roadblock is the error message you will get and you will get an error message. It will simply say “Not Found” or something to that effect, and you may be left scratching your head.
To make matters worse, you then use a .Take(500) on the Domain Service method and your data returns.
Now you are more confused.
What I will tell from here on applies to Silverlight project I was working on and therefore everything I say will be in that context using the Business Template. However, everything should be applicable to any project that you use WCF RIA Services.
WCF RIA Services have a limitation on how much data the domain service returns. And unfortunately there is no obvious place to configure this. And there are no samples on the web. They usually concentrate on bits and pieces but not the whole picture.
Once you know what to do, actually it’s all pretty easy and straight forward.
In the web.config, you have a section called <system.serviceModel>. Just go and add this piece of code, under that:
Code
<services>
<service name="YOUR_PROJECTNAME.Web.YOUR_DOMAINSERVICE" behaviorConfiguration="YOUR_PROJECTNAME-Web-YOUR_DOMAINSERVICE" />
</services>
<behaviors>
<serviceBehaviors>
<behavior name="YOUR_PROJECTNAME-Web-YOUR_DOMAINSERVICE">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
Pay attention to dots “.” and dashes “-“ in the code above as they are important.
And then… well, that’s it. What you’re doing is basically getting the end point to your web service, which is generated at runtime, and adjusting its maxItemsInObjectGraph property. The value we use is the highest for integer.