Note that there are some explanatory texts on larger screens.

plurals
  1. POria domain service is setting a client-side property on callback
    primarykey
    data
    text
    <p>I'm using RIA domain services, with entity framework 4 and silverlight 4. When I save changes, when the service call returns, some domain service functions are called wich sets a value to "" that should not be changed at all.</p> <p>I have two entities</p> <p>service.metadata.cs: </p> <pre><code>public partial class EntityA { [Key] public Guid EntityA_Id { get; set; } public string Name { get; set; } public int EntityB_Id { get; set; } [Include] public EntityB entityB { get; set; } } public partial class EntityB { [Required] public string Name { get; set; } public int EntityB_Id { get; set; } public EntityCollection&lt;EntityA&gt; entityA { get; set; } } </code></pre> <p>On the client side I have a Extra property on EntityA to expose the Name property od EntityB. The server side and domain service never need to know about this property, its for GUI only.</p> <pre><code>public partial class EntityA { //Tags I have tried: //[IgnoreDataMember] //[XmlIgnore] //[Ignore] //[Exclude] public string NameOf_EntityB { get { return this.entityB == null ? string.Empty : this.entityB.Name; } set { this.entityB.Name = value; } } } </code></pre> <p>If I edit the entityA's name and call serviceContext.SubmitChanges(), when the call returns some domain service process is setting the EntityA.NameOf_EntityB = ""; <strong>So from a user point of view, they save one value and the other blanks out.</strong> </p> <p>I need to stop this from happening. I have tried various data attributes, but they either don't work on the client side, or have no effect.</p> <p><strong>Any idea what to do to stop the domain service from changing this value?</strong> </p> <p>here's the callstack right before the value is changed:</p> <pre><code>System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.ObjectStateUtility.**ApplyValue**(object o, object value, System.Reflection.PropertyInfo propertyInfo, System.Collections.Generic.IDictionary&lt;string,object&gt; originalState, System.ServiceModel.DomainServices.Client.LoadBehavior loadBehavior) + 0x74 bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.ObjectStateUtility.ApplyState(object o, System.Collections.Generic.IDictionary&lt;string,object&gt; stateToApply, System.Collections.Generic.IDictionary&lt;string,object&gt; originalState, System.ServiceModel.DomainServices.Client.LoadBehavior loadBehavior) + 0x330 bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.Entity.ApplyState(System.Collections.Generic.IDictionary&lt;string,object&gt; entityStateToApply, System.ServiceModel.DomainServices.Client.LoadBehavior loadBehavior) + 0x68 bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.Entity.Merge(System.ServiceModel.DomainServices.Client.Entity otherEntity, System.ServiceModel.DomainServices.Client.LoadBehavior loadBehavior) + 0x5a bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.DomainContext.ApplyMemberSynchronizations(System.Collections.Generic.IEnumerable&lt;System.ServiceModel.DomainServices.Client.ChangeSetEntry&gt; changeSetResults) + 0x10e bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.DomainContext.ProcessSubmitResults(System.ServiceModel.DomainServices.Client.EntityChangeSet changeSet, System.Collections.Generic.IEnumerable&lt;System.ServiceModel.DomainServices.Client.ChangeSetEntry&gt; changeSetResults) + 0x262 bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.DomainContext.CompleteSubmitChanges(System.IAsyncResult asyncResult) + 0x1cb bytes System.ServiceModel.DomainServices.Client!System.ServiceModel.DomainServices.Client.DomainContext.SubmitChanges.AnonymousMethod__5() + 0x2e bytes </code></pre> <p><strong>Edit:</strong> found a work around for now. In the callback of the ServiceContext.submitChanges() call I can call ServiceContext.RejectChanges() to undo the change that was made to EntityB. I don't trust this solution though as other changes could have been made before the async call returns and those changes would be rejected as well. The ideal solution would be to have that value ignored and NOT set at all</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload