views:

42

answers:

1

When create .NET Ria Service Class Library, VS will create two projects: MyRiaServices(client side) MyRiaServices.Web(server side)

Suppose my entity model is in another project: MyData(entity framework)

There is an Entity People.

Then I want to use partial class to extend this entity in following way:

namespace MyData
{
   public partial class Person
    {
    //....
    }
}

If I do it in project MyData, it is fine.

But I want to do this way in project MyRiaServices.Web so that I can named the file as as person.shared.cs, but I failed. It give me error saying class definition conflict etc.

How to resolve this problem?

A: 

You can't use a partial class this way. The objective of the partial keyword is to allow two or more source files in compilation to contribute to the complete code of a single type. This allows auto-generated code created by designers to sit in a separate file from developer written code that then form a single class like Person.

However this mechisim is a compile time thing. You can't have an assembly expose a partial type which can be extended further with code compiled into a different assembly.

See the definition here.

AnthonyWJones