I'm using RIA services with Silverlight 4 and would like to limit the fields that are returned from the service. For example:
TableA:
ID
Field1
Field2
Field3
TableB:
ID
TableAID (foreign key)
Field1
RestrictedField2
In my domain service class I have something like this that was generated when I created the service. I added the includes (which are working fine):
<RequiresAuthentication()>
Public Function GetTableA() As IQueryable(Of TableA)
Return Me.ObjectContext.TableA.Include("TableB")
End Function
My question is, how do I get all of the columns from TableA and also get Field1 from TableB without returning the RestrictedField2? I'm pretty sure this is done through some Linq fanciness, but I'm not quite sure how.
Thanks! Matt
Update
One requirement that I didn't list above. The column must be removed on the server side as the data in RestrictedField1 cannot have any chance of being sent to the client. Also, I will need to use this field in a different domain service method (protected with RequiresRoleAttribute), so I can expose the information to an administrator. This requirement means that I don't want to create a different complex type and return that. I would prefer to continue working with the EF model type.
Based on some information that I found, the best way to accomplish what I need is to create a view in the database and expose the data I need via EF and RIA Services. This appears to be the best solution available.