WCF RIA SubmitChanges不会将主属性发送回服务器端 [英] WCF RIA SubmitChanges doesn't send master properties back to the server side
问题描述
看,我有这些非常简单的模型Master-Detail:
Look, I have these pretty simple model Master-Detail:
手是手指的大师(手指是手的细节)
Hand is master of Fingers (finger is a detail of hand)
所以在客户端:
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
在服务器端:
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 ;
}
}
问题实际上是关于不通过WCF导线发送回关联.因此,在服务器端,Hand属性为NULL,但不应(违反)-我只想刷新一下finger.Hand属性
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
这是metaAttribute类:
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; }
}
}
我在这里看到了相同的问题 http://forums.silverlight.net/forums/p/205220/480824.aspx ,但没人知道. 请帮忙!
I saw the same problem here http://forums.silverlight.net/forums/p/205220/480824.aspx, but nobody knows.. Please help!
谢谢!
推荐答案
如果您仍在使用RIA服务(而非数据服务)寻求帮助
If you are still looking for help with this using RIA services (as opposed to Data services)
最近,我已经在这两种技术上进行了相当多的工作,并且在您上面发布的SL论坛链接中提供了一些信息:
I've worked quite a bit with these 2 technologies in the recent past and I provided some information on the SL forums link you posted above:
一对多关联在服务器端为空" (forums.silverlight.net)
"One to many association is null on Server side" (forums.silverlight.net)
这篇关于WCF RIA SubmitChanges不会将主属性发送回服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!