Introducing RadDomainDataSource for Silverlight

by XAML Team | Comments 15

ddsam happy to announce that we have added a new data control to our Silverlight portfolio with one of our latest internal builds. The control will have its official premiere with the upcoming 2010 Q3 Service Pack 1, which is expected in early January. With the release of this service pack you will get access to all of RadDomainDataSource online examples. Since the first version of RadDomainDataSource is now 100% feature complete and has already passed QA, we have decided that we might as well share it with you as a small Christmas present.

RadDomainDataSource is a Silverlight control that provides the missing link between Telerik Data Controls and WCF RIA Services. Make sure that you are Understanding the WCF in ‘WCF RIA Services’ before you read on.Architecture

Up until now, controls like RadGridView, RadDataPager and RadDataFilter did their job solely on the client. You had to write tons of extra code if you wanted to transfer these operations on the server by using the stock DomainDataSource control. Furthermore, things like composite filtering were simply impossible to do with the default DomainDataSource. Now all you need to do is simply bind a Telerik data control to RadDomainDataSource and it will automatically do its job on the server.

When you create a new RIA-enabled Web Application a domain context class is automatically generated in the client project. This domain context is the proxy between the client and the domain service. You could always use this domain context directly and call methods on it to interact with the server. But you will have to handle all the data going back and forth yourself. What RadDomainDataSource offers is to do this job for you automatically. The only two things that RadDomainDataSource needs in order to operate are the domain context and the name of the query method on the server. From then on, RadDomainDataSource will manage all your queries and the data that the server returns. Simply bind RadGridView to RadDomainDataSource.DataView property and you are set.RDDS

For those of you who follow the MVVM pattern strictly, we have exposed RadDomainDataSource’s internal view as a public class. It is called QueryableDomainServiceCollectionView<T> and does just what its name suggests – provides a view over a collection of domain service entities. You can use this class directly in your view models. This is the class responsible for all of the heavyweight lifting. In fact, you can think of RadDomainDataSource as just a very thin wrapper over the Queryable Domain Service Collection View which makes it XAML friendly.

Before you ask, I am currently preparing a whole series of blog posts in which I will discuss and explain topics such as:

  • Loading, filtering, sorting, and paging data (there is no real grouping in WCF RIA yet)
  • Editing and submitting data (CRUD)
  • Query parameters and stored procedures
  • Distinct values
  • Load delay
  • RadDataFilter integration
  • RadDomainDataSource in master-detail scenarios
  • RadDomainDataSource in row details scenarios

I will welcome any suggestions for other possible topics that you want me to cover.

I have prepared and attached a very simple project utilizing RadDomainDataSource, RadGridView and RadDataPager. RadDomainDataSource is located in a new assembly called Telerik.Windows.Controls.DomainServices.You can find the licensed version of this assembly in the internal build from the 20th of December. The latest internal build should be available in your Telerik accounts. The project is also using WCF RIA Services V1.0 SP1 Beta. Here is everything that it takes to bind a grid and a pager to the domain data source:

  1. <telerik:RadDomainDataSource
  2.     x:Name="customersDataSource"
  3.     AutoLoad="True" QueryName="GetCustomers"
  4.     PageSize="10"
  5.     LoadingData="OnCustomersDataSourceLoadingData"
  6.     LoadedData="OnCustomersDataSourceLoadedData">
  7.     <telerik:RadDomainDataSource.DomainContext>
  8.         <e:NorthwindDomainContext />
  9.     </telerik:RadDomainDataSource.DomainContext>
  10. </telerik:RadDomainDataSource>
  11.  
  12. <telerik:RadBusyIndicator
  13.     IsBusy="{Binding IsBusy, ElementName=customersDataSource}">
  14.     <telerik:RadGridView
  15.         x:Name="radGridView"
  16.         Grid.Row="0"
  17.         ItemsSource="{Binding DataView, ElementName=customersDataSource}"
  18.         DistinctValuesLoading="OnRadGridViewDistinctValuesLoading"
  19.         ShowGroupPanel="False"
  20.         IsReadOnly="True"/>
  21. </telerik:RadBusyIndicator>
  22. <telerik:RadDataPager
  23.     x:Name="radDataPager"
  24.     Grid.Row="1"
  25.     Source="{Binding DataView, ElementName=customersDataSource}"
  26.     DisplayMode="All"
  27.     IsTotalItemCountFixed="True"/>

You can use this sample project to play around with the new control and let me know what you think. You can either post a comment here or send me a message on twitter.

Download Sample Project

Merry Christmas and a Happy New Year to you and your families!


Senior Software Developer,
Telerik XAML Team

Posted in: raddomaindatasource

15 Comments

Charlie
Thanks.  This is good and exciting.  Vlad had mention that the Q3 SP1 would be ready last week, and then he said this week, and now you are saying earlier next month.   What is the actual date for the release?
Jonx
Hello... I'm not sure to get what the differences between the WCF RIA Services DomainDatasource and the RadDomainDatasource are. Do you mean for example that right now, when I use a RadGrid connected to a DomainDatasource, I have all the data on my client and when I clic on a column to sort my data it gets sorted on the client side? And now with the RadDomainDatasource it will sort the data on the server? But then will it have to transfert the sorted data back to the client... Is this faster? Anyway, please give me more samples based on normal simple DomainDatasource operations.
Thank you, John.
Rossen Hristov
Hello John,

The difference is the following. Let's assume that you want to filter on the server. Up until now you did in the following way:

1. Click a filtering funnel in RadGridView and enter some filtering criteria.
2. This performs filtering on all data that is currently residing on the client.
3. You listen for the Filtering event of the grid.
4. Once the filtering event happens, you take all the filtering criteria and translate it to the FilterDescriptors that the MS DomainDataSource understands.
5. The MS DomainDataSource filters on the server and returns the data.
6. The grid is updated with the new data coming from the server.

One limitations of the MS DomainDataSource is that it does not support composite filtering. For example if you want to say -- Give me all people that are (younger than 18 OR older than 60) AND (are from Spain) you can't do this out-of-the-box with the DomainDataSource control.

When you use RadDomainDataSource here is what happens:

1. Click a filtering funnel in RadGridView and enter some filtering criteria.
2. RadGridView "knows" that its ItemsSource (RadDomainDataSource.DataView) implements the IQueryableCollectionView interface and thus it automatically transfers the created FilterDescriptors to it.
3. Once RadDomainDataSource received these FilterDescriptors it goes to the server, pull the needed data and RadGridView is automatically updated to show the new data.

The sample integration scenario applies for RadDataPager and RadDataFilter. When you bind their Source to RadDomainDataSource.DataView they start to page and filter directly on the server.

The main benefit is that you do not have to a write any additional code to synchronize Telerik's descriptors with those of Microsfot. Since RadGridView, RadDataPager, RadDataFilter and RadDomainDataSource are all part of the same portoflio, when they are bound together they kind of "sniff" each other and start synchronizing without any additional source code.

In my blog post, there is a link called "tons of extra code". Follow it and you will see the amount of code you had to write in order to synchronize RadGridView's filtering with that of the DomainDataSource. The same applies for sorting and paging. Grouping is really not important here since WCF RIA Services do not support real grouping on the server. They simply return the data sorted according to the grouping criteria.

I hope this explains the whole thing to some extent. Let me know if I can help in any other way.

Let me know if you have any other questions.
Rossen Hristov
Hello Charlie,

We had to postpone the service pack due to unforseen circumstances. You know how it is.

But the RadDomainDataSource control is as "official" now as it will be with the Service Pack. So you can either wait for the Service Pack (mid January -- I really can't tell the date, since it does not depend on me) or you can get the control from the Latest Internal Build and give it a spin.

Happy Holidays!
Rossen Hristov
Hello Charlie,

I am not sure what these fixes were supposed to be. Could you elaborate a little bit more.

But since this is really not the right place to be talking about the other blog, why don't you ask this question under the respective blog post or send a separate support ticket. I don't want to spam this blog's comments.
Jaime Bula
Is this only for WCF Ria services, or is there a way to make it work with plain WCF services.

Best Regards.
Rossen Hristov
Hello Jaime,

Currently we have a data source control for WCF RIA Services only, but we have plans to develop other data source controls, one of which will hopefully handle plain WCF Services.
Chris Parker for Raymond

Hi Rossen,

I structured my, at this time small project, to work just like this example. I'm the guy from the blog that originally asked this question about MVVM, gridview, etc.

Problem is when I set the PageSize on the RadDomainDataSource (RDDS) I get that pesky 4004 error when loading the data. I have the RDDS set to AutoLoad=True. When I set it to false and manually Load I get the same error.

I don't get an error when I don't do paging, but I can't have the user wait 45 seconds to load 1400 records. My original project used MVVM but I built a small subset project just using RIA/Silverlight to break it down to it's simplest form. I got this 4004 error when trying to use the MS DDS. Maybe I'm doing something wrong.

My Domain Service on the server at this time only has one method but it's an import function as the information is drawing from a stored procedure. I wouldn't think that would matter as I still return an entity it's just a complex type not just a table.

Do you have any ideas why I would get this 4004. Just to add this to you and the other readers, I have did a ton of research on this and some fixed the problem by putting a OrderBy on my call and I do that. It looks like this;

        /// <summary> 
        /// Returns all products to display on the dashboard.  
        /// </summary> 
        /// <returns></returns>  
        [Description( "Returns all products to display on the dashboard." )]  
        public IQueryable<GetProductsDashboard_Result> GetProductsDashboard()  
        {  
            return this.ObjectContext.GetProductsDashboard().OrderBy( c => c.Id ).AsQueryable(); 
        } 
Chris Parker for Raymond
Please ignore my post above, I figured it out. I replaced my return line of code with the following;
return ( IQueryable<GetProductsDashboard_Result> )this.ObjectContext.GetProductsDashboard().OrderBy( c => c.Id ).ToList().AsQueryable(); 
 
 
 

That did the trick. New RadDomainDataSource control works great for me and the sample helped also. Keep up the good work.
Rossen Hristov
Hello,

The MVVM blog post is already published, so you might find it interesting.
Chris Parker
Hi Rossen,

I left a post in the beta forum for you but I guess the administrators deleted it. In your sample applications you use the following code;
private static Expression<Func<Customer, string>> CreateSelectorExpression(string propertyName) 
        var paramterExpression = Expression.Parameter(typeof(Customer)); 
    return (Expression<Func<Customer,string>>)Expression.Lambda(Expression.PropertyOrField(paramterExpression, propertyName), paramterExpression); 

This code works great if the filed from the database is a varchar/nvarchar but you get an error if the field is a Int32/int. Do you have any idea how it can work with any field type?
Rossen Hristov
Hello,

It seems that the post was hidden because I moved it under RadDomainDataSource. I will move it back where you posted it. Here is the link:

http://www.telerik.com/community/forums/silverlight/beta/raddatadomainsource-syntax-rossen-blog-sample.aspx

I hope this helps.
Amit Hiremath
Hello This is a great feature, especially the composite filtering, with domain data source and RIA service.

Do let me know if it si available in the current release.

Becuse we are planning to buy it for one of our customers.
Amit
Dempsey
Hi, Rossen.
In this article, you said:

>> Before you ask, I am currently preparing a whole series of blog
>> posts in which I will discuss and explain topics such as:

  • Loading, filtering, sorting, and paging data (there is no real grouping in WCF RIA yet)
  • Editing and submitting data (CRUD)
  • Query parameters and stored procedures
  • Distinct values
  • Load delay
  • RadDataFilter integration
  • RadDomainDataSource in master-detail scenarios
  • RadDomainDataSource in row details scenarios
I've searched all over but can't find the rest of these blog posts you promised. I did find your one other blog post, but not all the others you've listed. Will you be doing those? It sure would be nice. The RadDomainDataSource isn't as straightforward as you might assume, at least for someone like me who is new to the subject.
Thanks,
Dempsey

Comments

  1.    
      
      
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)
Read more articles by XAML Team - or - read latest articles in Developer Tools