RIA Services – sample

This sample doesnt do a whole lot but, I had to post in the forums twice to even get this working. so I thought it might be helpful to point out some of the issues I faced and how to solve similar problems. All it does is display list of customers and when you click on details, it shows details of the customer and his orders in a childwindow

The following is the reply clarfying the scenario from David
To be clear regarding EF and DomainDataSource, this is not a general issue — it should only present itself when a LoadSize is set because EF doesn’t support Skip() and Take() on unordered data. This would be the case even if you were using the underlying DomainContext to perform the same operations.

Ultimately, it’s an EF limitation. As long as the queries on your DomainService support Skip and Take, you can expect the DomainDataSource to work just fine (with LoadSize and PageSize) with them. Similarly, if your DomainService queries don’t support OrderBy(), ThenBy() or Where(), you shouldn’t expect sorting, grouping, or filtering to work using the DomainDataSource. Nonetheless, we’re looking at some ways to make it less likely that people will encounter this issue.In regards to your other issue with the DataPager, there may be a bug here that we will look into. My hunch is that it’s a timing issue, which is why setting the PageSize on the DDS fixes the problem.”

ria41
ria42
1. if we are using EntityFramework then the DomainDataSource  might not work correctly. you have to specify SortDescriptors(in bold)

  <riaControls:DomainDataSource x:Name=”source” LoadSize=”30″   LoadMethodName=”LoadCustomers” >
            <riaControls:DomainDataSource.DomainContext>
                <ds:NorthwindContext/>
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.SortDescriptors>
                <riaData:SortDescriptor PropertyPath=”CustomerID” Direction=”Ascending” />
            </riaControls:DomainDataSource.SortDescriptors>
        </riaControls:DomainDataSource>

2. I Had a situation where I am calling a parameterized constructor

Details details = new Details((sender as Button).DataContext as Customers);
            details.Show();

and in the details page

public Details(Customers c)
        {
            InitializeComponent();          
            dataForm1.CurrentItem = c;
Parameter p = new Parameter();
            p.ParameterName = “customerId”;
            p.Value = c.CustomerID;
            source.LoadParameters.Add(p);
            source.Load();
        }

The above code is throwing exceptions when PageSize is specified on the DataPager, to get around that we need to specify on the DomainDataSource

you can download the code here (it is a bit big as database is also included in it)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s