1
votes

I've got an application set up with RIA Services, Entity Framework 4, and Silverlight 4. It is set up in the standard fashion prescribed on MSDN here: Walkthrough: Creating a RIA Services Solution

I've written a new method (or property) against one of the entity objects which resides on the server; I would like this method (or property) to also be generated (automagically) on the client. i.e.

  • I have a table in my database called Customer which has two fields: FirstName and LastName
  • (ASP.NET project - server side) EF has created a corresponding partial class called Protocol that has two properties: FirstName and LastName
  • (ASP.NET project - server side) In another file, I'm using the partial class mechanism to define a method (or property) to return the FirstName and LastName together in a string, e.g.
    • public function ReturnFullName() as String ...
    • public property FullName() as String ...

Is there a way for ReturnFullName() and FullName() to be generated in on the client side (my Silverlight application)? Or do I have to implement the method / property on the client side as well?

2

2 Answers

0
votes

Methods in your Domain objects on the server side are not generated on the client side. (One reason for that is that obviously you could use .NET Framework features in these methods that are not available in Silverlight.) Properties are just copied with their signature, using class variables.

A solution to that problem is having a partial .cs file for your Customer class where you define these methods and create a link to that file in your Silverlight project. Of course, you can only use libraries in the using statements that are also available in Silverlight.

0
votes

Create a .shared.cs or .shared.vb file with a partial class of the entity in it.

For example:

Partial Public Class Persoon
    Public Function GetFullName() As String
        Return Me.Voornaam & " " & Me.Naam
    End Function
End Class


public partial class Persoon
{
    public string GetFullName()
    {
        return this.Voornaam + " " + this.Naam;
    }
}

It will then generate on client side to.