Note that there are some explanatory texts on larger screens.

plurals
  1. PODomain Service Named Method Update not working
    primarykey
    data
    text
    <p>I am using VS 2010 and Silverlight 4 and WCF RIA v1</p> <p>I am getting a strange error when I try to use a named update method in the domain service. </p> <p>This is the error:</p> <p>"Message: Unhandled Error in Silverlight Application *<em>Submit operation failed. Value cannot be null.</em>*Parameter name: original at System.ServiceModel.DomainServices.EntityFramework.ObjectContextExtensions."</p> <p>Error happens here in the domain service this.ObjectContext.Prospects.AttachAsModified(p, this.ChangeSet.GetOriginal(p));</p> <p>I have read the change documentation for WCF and I think I am doing everything right.</p> <p>Could someone please help me to figure out wha is going on?</p> <p>Cheers</p> <p>This is the code explanation:</p> <h2>Client</h2> <p>.....</p> <pre><code>&lt;riaControls:DomainDataSource.DomainContext&gt; &lt;my:MarketingDomainContext /&gt; &lt;/riaControls:DomainDataSource.DomainContext&gt; </code></pre> <p>.....</p> <pre><code>&lt;Grid x:Name="LayoutRoot" Background="White"&gt; &lt;Grid DataContext="{Binding ElementName=comboBoxProspects, Path=SelectedItem}" Name="gdProspects" Margin="10"&gt; </code></pre> <p>....... .......</p> <p>I grab the Prospects entity from the Grid.</p> <p>I have tried to call the named update method using both the context declared globally and the update method int Entity.</p> <pre><code>public partial class MainPage : UserControl { MarketingDomainContext ctx; private void dsProspects_LoadedData(object sender, LoadedDataEventArgs e) { ctx = (MarketingDomainContext)dsProspects.DomainContext; } private void btnSubmit2_Click(object sender, RoutedEventArgs e) { //((Prospect)gdProspects.DataContext).CalculateProspectValue( // int.Parse(tbNumber1.Text), int.Parse(tbNumber2.Text)); var tempProsp = gdProspects.DataContext as Prospect; ctx.CalculateProspectValue(tempProsp, int.Parse(tbNumber1.Text), int.Parse(tbNumber2.Text)); ctx.SubmitChanges(); } </code></pre> <h2>Domain Service method</h2> <pre><code>[Update(UsingCustomMethod=true)] public void CalculateProspectValue(Prospect p, int a, int b) { p.Comments = "Value = " + a * b; // Error happens here this.ObjectContext.Prospects.AttachAsModified(p, this.ChangeSet.GetOriginal(p)); } public void UpdateProspect(Prospect currentProspect) { this.ObjectContext.Prospects.AttachAsModified(currentProspect, this.ChangeSet.GetOriginal(currentProspect)); } </code></pre>
    singulars
    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