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: