RIA Services and relational data

Source: Internet
Author: User
Tags silverlight

As we all have sin, when you look at some technical demonstrations, most examples show a single table solution. Can you remember when you last developed a system of one-meter?

In the demonstration of RIA services, most of them are also examples of single tables. So how do you retrieve relational (master/structure) data through Ria? I use the VS2010, Silverlight 4, and WCF RIA Services preview to demonstrate the following examples. I also used the Chinook (helicopter) sample database, which is one of my favorite simple relational data examples.

Create a project with RIA Services

This is easy, you just create a new Silverlight project and make sure that enable. NET RIA Service is selected (yes, it is not called WCF in the dialog box). The program can retrieve the artist and its related albums by clicking on a simple button. These are the initial XAML:

1: <grid x:name= "LayoutRoot" background= "White"
2: <stackpanel width= "n"
3: & Lt Button content= "Get Artist Information" x:name= "Getartistbutton" click= "Getartistbutton_click"/>
4: <st                 Ackpanel orientation= "Horizontal"
5: <stackpanel x:name= "Artistscontext"
6:                     <stackpanel orientation= "Horizontal"
7: <textblock text= "Artists:"/>
8: <textblock text= "{Binding elementname=listofartists, path=items.count}"/>
9: < /stackpanel>
: <listbox x:name= "listofartists" width= "height=" "Displaymemberpath=" Nam E "itemssource=" {Binding} "/>
One: </stackpanel>
: <stackpanel x:name=" Albumsc Ontext "
: <stackpanel orientation=" Horizontal "
: <textblock text= "Albums:"/>
: <textblock text= "{Binding elementname=listofalbums, path=items.count}"/>
16: </stackpanel>
<listbox: X:name= "listofalbums" displaymemberpath= "Title" Itemsso Urce= "{Binding}" width= "height="/>
: </stackpanel>
: </StackPanel>
: </stackpanel>
: </grid>

Now we're going to create the relevant model and the domain service being invoked on the server side. The model I created with the Entity Framework (Entity framework, need. NET 4) looks like this:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.