I'm making a Silverlight 4 application with WCF RIA Services.
On the server side (the *.Web
project), I have an Entity Model that's auto-generated from a SQL Server database.
On the client side, I have the domain service and proxy objects that are generated by Visual Studio for use in Silverlight assemblies.
I want to add custom properties to the model (preferably on the server side).
Say I have Contact
, Company
, and Address
tables, which are linked by foreign keys (but not necessarily actual foreign key constraints). I want to add a property that will return a Contact
's Company
's Address
object.
I have been attempting to do this by making a partial class to extend the Contact
class, and adding a CompanyAddress { get; }
property. But I have no idea what I need to do with the new property in order to make it propagate to the auto-generated code on the client side. Are there specific attributes I have to add to the property? Do I have to register it somewhere so that the code generator will know about it?
Does this have to be a Navigation Property or can it be something simpler?
And is this even the best way to do things, or should I give up on extending the server-side model and just do it on the client side? (If I do it on the client side, I face the problem of not having access to the context object inside the individual Entity
-derived classes.)