tags:

views:

31

answers:

1

I am trying to use NHibernate with RIA Services. Currently I have two entities:

public class Person{
    [Key]
    public virtual int Id {get; set;}
    [Include]
    [Association("CurrentEmployer", "CurrentEmployerId", "Id", IsForeignKey = true)]
    public virtual Employer CurrentEmployer { get;set;}
    public virtual int? CurrentEmployerId {get;set;}
}
public class Employer{
    [Key]
    public virtual int Id {get;set;}
    public virtual string Name {get;set;}
}

When I get a person entity through Ria on the client side the CurrentEmployerId is set but the CurrentEmployer is still null. On the server side, both the CurrentEmployerId and the CurrentEmployer are properly populated. Both the Employer entity and the Person entity are exposed in the same Domain Service.

How do I get the CurrentEmployer to be populated on the client side when I get a person? Am I missing an attribute?

A: 

I discovered why the CurrentEmployer was null. I detached the Person from the DomainContext

_domainContext.People.Detach(foundPerson);

before I accessed the CurrentEmployer property.

Maudite