Look, I have these pretty simple model Master-Detail:
Hand is master of Fingers (finger is a detail of hand)
So on the client side:
Hand hand = domainService.Hands[0]; // get some hand, doesn't matter
...
Finger f = new Finger() { f.Id = Guid.NewId() };
f.Hand = hand; // make connection !!
domainService.Fingers.Add(f);
domainService.SubmitChanges(OnSubmitCompleted, null); // error is here
On the Server Side:
public void Insert<T>(T obj)
{
try
{
using (ISession session = _factory.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
session.SaveOrUpdate(obj); // NHibernate error: not-null property references a null or transient value
transaction.Commit();
}
}
catch (Exception ex)
{
throw ;
}
}
The problem actually is about not sending associations back via WCF wire. So On the server side the Hand property is NULL, but it shouldn't (violation) - I just want to refresh my finger.Hand property
It's not even a composition - I don't need this cause of its limitations
here is the metaAttribute class:
[MetadataType(typeof(Finger.FingerMetadata))]
public partial class Finger
{
//[Required(AllowEmptyStrings = true)]
//[Exclude]
public virtual Guid HandID { get; set; }
//{
// get { return Hand.Id; }
//}
internal sealed class FingerMetadata
{
[Key]
public Guid Id { get; set; }
[Include]
//[RoundtripOriginal]
//[ExternalReference]
[Association("Finger-Hand", "HandID", "Id")]
//[ConcurrencyCheck]
//[Composition]
public Hand Hand { get; set; }
}
}
[MetadataType(typeof(Hand.HandMetadata))]
public partial class Hand
{
internal sealed class HandMetadata
{
[Key]
public Guid Id { get; set; }
[Include]
//[ExternalReference]
[Association("Hand-Finger", "Id", "HandID")]
//[Composition]
public IList<Finger> Fingers { get; set; }
}
}
I saw the same problem here http://forums.silverlight.net/forums/p/205220/480824.aspx, but nobody knows.. Please help!
Thanks!