开发者

Ria Services not populating complex properties on the client side

I am trying to use NHibernate with RIA Services. Currently I have two entitie开发者_运维百科s:

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?


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

_domainContext.People.Detach(foundPerson);

before I accessed the CurrentEmployer property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜