views:

50

answers:

0

I am working on a silverlight application and I am using RIA data services and nHibernate.

Currently, I have an entity with a one to many relationship to another entity.

public class Employer {
    [Key]
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
}

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

The property CurrentEmployerId is set for no insert and no update in the mappings.

On the Silverlight side, I set the CurrentEmployer property of the person to an existing employer on the client side submit the changes.

personEntity.CurrentEmployer = megaEmployer;
dataContext.SubmitChanges();

On the server side, the person entity's CurrentEmployerId is set to megaEmployer.Id but the CurrentEmployer is null. Because I am using the CurrentEmployer property and not the CurrentEmployerId to save the relationship, the relationship isn't changed.

Is there a way to force RIA to send the CurrentEmployer object with the save or do I have to use the CurrentEmployerId on the server side to load the employer and set it to the CurrentEmployer?