silverlightwcf-ria-servicesdomaindatasource

Using Silverlight RIA Services DomainDataSource to query by user


So I am using the SL4 Business Template and the SQL Membership API. I created a user and I created a custom table that ties to that user.

So I want to have a datagrid that show the item for the CURRENT (WebContext.Current.User) user.

  1. Why is the GUID for the user in WebContext.Current.User??? I need that to join to the 'Items' table.

  2. How can I use the XAML DomainDatasource... from what I see you can only use it if you can bind to something else on the XAML.. for example if I have a calendar control on the page I can bind the domaindatasource to the calendar.... But I want to query giving the 'UserID (GUID)'... so do I need to put a hidden field on the XAML with that value to have access to it? (like the hidden fileds in asp.net)

or am I going about it all the wrong way... its a really simple conceopt.. I have users.. I have items.. there is a relationship.. and I want a datagrid filled with items for a particular user.


Solution

  • There are two ways to approach this. First, you could just write a query GetDataForCurrentUser() and pull the current user on the server. This tends to be the more secure option since a user can only get their own data. The second option is to pass the user guid as a parameter. In this post, I show a couple ways to do just that.

    http://jeffhandley.com/archive/2010/03/18/custom-filter-parameter.aspx