SilverlightShow: WCF RIA Services Part 3: Updating Data Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) Re: WCF RIA Services Part 3: Updating Data <p>Just get a reference to your domain context object and call it?</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment8496 brian.noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sun, 23 Sep 2012 17:31:29 GMT Re: WCF RIA Services Part 3: Updating Data How to call <strong>SubmitChanges() </strong>When OK button in a dataform is cliked? http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment8495 haiyun592 http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sun, 23 Sep 2012 17:05:37 GMT Re: WCF RIA Services Part 3: Updating Data <p>Haiyun592, if that represents the IP address the client is supposed to use to get to the domain service, you have a chicken-egg problem there. But if that is just random piece of data you want to expose, you could just make it an [Invoke] method if it is just using primitives for the parameters and return type.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7558 brian.noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Mon, 20 Feb 2012 20:31:36 GMT Re: WCF RIA Services Part 3: Updating Data <p>Brian,</p> <p>Suppose I create the following code in the Domain Service</p> <p>public string GetClientIP()</p> <p>{</p> <p>    return "192.168.4.5";</p> <p>}</p> <p>How can I consume it in the client side?</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7557 haiyun592 http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Mon, 20 Feb 2012 20:28:09 GMT Re: WCF RIA Services Part 3: Updating Data <p>Impossible to say with so little information.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7551 brian.noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 18 Feb 2012 22:45:10 GMT Re: WCF RIA Services Part 3: Updating Data <p>I have a Update button in the UI with the following event handler</p> <p>        private void updateTaskButton_Click(object sender, RoutedEventArgs e)<br />         {<br />             taskDomainDataSource.SubmitChanges();<br />         }</p> <p>After adding a new task when I try to update columns which are empty such as Customer Id and Project Id I can see them in the UI, but it is not updated in the database. But the columns which already has a value such as Description, EndDate, StartDate and Taskname are getting updated in the database when I click the update button. So what is happening here? </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7547 PremkumarJanagarajan http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 18 Feb 2012 11:38:03 GMT Re: WCF RIA Services Part 3: Updating Data <p>Could you give a little more information? Where are you observing this, with SQL Profiler at the database, in server code or client code? Which fields are you changing and which are you saying are changing that you did not edit. Need more of a repro than that question to help.</p> <p>Thanks, Brian</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7543 brian.noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 17 Feb 2012 13:45:49 GMT Re: WCF RIA Services Part 3: Updating Data <p>Hi,</p> <p>When I try to update, the columns which already has a value are the ones getting updated. Those columns which doesn't have a value is not getting updated. What is happening here? </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7542 PremkumarJanagarajan http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 17 Feb 2012 13:03:46 GMT Re: WCF RIA Services Part 3: Updating Data <p>Caro Amigo,</p> <p>Li o seu artigo que esta me ajudando muito, teria como o Sr. exemplicar de como ficaria o UPDATE detse exemplo?</p> <p><br /> </p> <p>Att,</p> <p>Mariel</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment7267 mfeitosa http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Mon, 28 Nov 2011 01:55:31 GMT Re: WCF RIA Services Part 3: Updating Data <span style="font-family: lucida console; font-size: 18px;">I actually found a method to make it work: <p> </p> <p>SQL View</p> <p>SELECT     dbo.tlkp_PhoneType.PhoneTypeID, dbo.tlkp_PhoneType.PhoneType, CASE WHEN dtUsageCount.UsageCount IS NULL <br />                       THEN 0 ELSE dtUsageCount.UsageCount END AS LookupUsageCount<br /> FROM         dbo.tlkp_PhoneType LEFT OUTER JOIN<br />                           (SELECT     PhoneTypeID, SUM(Expr1) AS UsageCount<br />                             FROM          (SELECT     PhoneTypeID, COUNT(ClientPhoneID) AS Expr1<br />                                                     FROM          dbo.tbl_ClientPhone<br />                                                     GROUP BY PhoneTypeID<br />                                                     UNION ALL<br />                                                     SELECT     PhoneTypeID, COUNT(NamePhoneID) AS Expr1<br />                                                     FROM         dbo.tbl_NamePhone<br />                                                     GROUP BY PhoneTypeID) AS dtUsage<br />                             GROUP BY PhoneTypeID) AS dtUsageCount ON dbo.tlkp_PhoneType.PhoneTypeID = dtUsageCount.PhoneTypeID</p> <p>Then, using something like the following in Silverlight...</p> <p>Boolean CheckForUsage()<br /> {<br /> tlkp_Citizenship vCit = (tlkp_Citizenship)dg.SelectedItem;<br /> string strCitizenshipDesc = vCit.CitizenshipDesc;<br /> System.Collections.Generic.IEnumerable<vUsageCount_Citizenship> q = colHM.Where(p => p.CitizenshipDesc == strCitizenshipDesc && p.LookupUsageCount > 0);<br /> Int16 count = 0;<br /> foreach (vUsageCount_Citizenship i in q)<br /> {<br />     count += 1;<br /> }<br /> if (count > 0 )<br /> {<br />     return true;<br /> }<br /> else<br /> {<br />     return false;<br /> }<br /> }</p> <p> </p> </span> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6276 raibeart http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 09 Jun 2011 17:06:35 GMT Re: WCF RIA Services Part 3: Updating Data <p>Brian,</p> <p>1. Referential Integrity is set with foreign key relationships (I am also a SQL Server DBS and know database design quite well)</p> <p>2.  I get an error when exiting the function that does the delete.  Not at the commit of the delete. So, I cannot trap the error.  I have tried the try/catch functionality.</p> <p>3.  What has to happen is to check and see if the record has been used.  I the usage count is 0, then I can delete it, otherwise, I need to tell the user it cannot be deleted because it is being used.  Of course, if I was dfoing a logical delete using a IsDeleted boolean flag, I would not need to do any of this, but that is a very big change to the database.</p> <p>So, what I am trying to do is either catch the error, or otherwise check to see if the lookup record has been used.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6275 raibeart http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 09 Jun 2011 16:59:59 GMT Re: WCF RIA Services Part 3: Updating Data <p>I'm not clear on what you are trying to do. If you have referential integrity on and there are FKs pointing to it, you shouldn't be able to delete it, that is the whole point.</p> <p>Are talking about on the client side or server side?</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6265 brian.noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 09 Jun 2011 03:02:48 GMT Re: WCF RIA Services Part 3: Updating Data <p>I am having no problem with CRUD functions except for the following:</p> <p>I have a lookup table.  If I try to delete a row in the lookup table that is being used as a foreign key in another table, I get an error.  But only after I exit the function.  I cannot trap the error with a try/catch. I have created views on the server that returns back the ID, the description, and the number of times it is used.  If the usage count = 0, then I can delete it.  I am loading this at the same time as I load the form.  I am loading it into an ObservableCollection.</p> <p>How can I validate that I can delete a record with referential integrity turned on?</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6264 raibeart http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Wed, 08 Jun 2011 21:02:38 GMT RE: WCF RIA Services Part 3: Updating Data <p>Very cool... That removes another few lines of code!</p> <p>Thanks Brian</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6098 Tim http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Mon, 09 May 2011 14:04:29 GMT RE: WCF RIA Services Part 3: Updating Data When you call SubmitChanges, it actually returns the collection of updated entities to the client for things like server computed IDs. So if you check your entity after you get an SubmitChanges Completed event or callback, the id should be there. http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6083 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sun, 08 May 2011 00:48:11 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hello,</p> <p> </p> <p>Getting alot out of this series - so thanks.</p> <p>I would like to retreive the ID of a recently inserted entity. How is this best acheived using RIA? There doesn't appear to be a list of entites available in the SubmitOperation, only EntitiesInError.</p> <p> </p> <p>Thanks,</p> <p> </p> <p>Tim</p> <p></p> <pre style="font-family: consolas; font-size: 13px; color: black; background: none repeat scroll 0% 0% white;"><span style="color: blue;"></span></pre> <p></p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment6082 Tim http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 06 May 2011 17:50:17 GMT RE: WCF RIA Services Part 3: Updating Data RE: How to Update a Record ? Help me, please! thanks<br /> <br /> I had the same problem and through SQL Profiler found out, I accidently mapped  a stored procedure to my entity's update function, so the stored procedure kept being called instead of the Update. For mapping and unmapping entity  to Stored Procedures see the following article:<br /> <br /> <a href="http://msdn.microsoft.com/en-us/library/cc716679.aspx"><span style="font-size: 16px;">http://msdn.microsoft.com/en-us/library/cc716679.aspx</span></a><br /> <br /> <span style="font-size: 16px;">I hope this helps someone!<br /> <br /> </span> <p>Bore</p> <p> </p> <p> </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment5234 Bore http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Wed, 05 Jan 2011 10:44:36 GMT RE: WCF RIA Services Part 3: Updating Data Namtran, Just retrieve your entity or entities, keep the domain context alive by keeping it in a member variable, modify the entity that you want to update, and call SubmitChanges on the domain context. http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment5212 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 01 Jan 2011 20:22:43 GMT RE: WCF RIA Services Part 3: Updating Data <p>How to Update a Record ? Help me, please! thanks</p> <p>i had done same to Add a Record, so it's failed.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment5205 namtran http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 01 Jan 2011 10:29:01 GMT RE: WCF RIA Services Part 3: Updating Data <p>Awesome</p> <p>Very helpful for the beginners </p> <p>woopieee :) </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4964 aarti291184 http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 26 Nov 2010 09:40:58 GMT RE: WCF RIA Services Part 3: Updating Data implemented <p>contextSubmitChanges(OnSubmitChangesComplete, null);</p> <p>private void OnSubmitChangesComplete(SubmitOperation so)<br /> {<br />     if (so.HasError)<br />     {<br />         // handle so.Error<br />     }<br />     else<br />     {<br />         // success<br />     }</p> <p>}</p> <p> </p> <p>it is not going into exception.</p> <p>so code is executing correct.</p> <p>but not saving data in database.</p> <p>Many forums tells that child window shud hv samae domain context instance as Master form.</p> <p>So my question is how to maintain the same domain context on both Master and child form?</p> <p>I think in my case this is the problem that master domain context is getting null when child form gets loaded.</p> <p>please help.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4917 Silver123 http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 19 Nov 2010 08:32:24 GMT RE: WCF RIA Services Part 3: Updating Data <p>Silver123, you need to check for errors when you submit.</p> <p>contextSubmitChanges(OnSubmitChangesComplete, null);</p> <p>private void OnSubmitChangesComplete(SubmitOperation so)<br /> {<br />     if (so.HasError)<br />     {<br />         // handle so.Error<br />     }<br />     else<br />     {<br />         // success<br />     }</p> <p>}</p> <p><br /> </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4910 Chris Bordeman http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 18 Nov 2010 22:04:16 GMT RE: WCF RIA Services Part 3: Updating Data Sorry Silver123, no way to tell from what you are describing and I can' help every reader debug every line of code of their apps. http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4897 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 18 Nov 2010 13:13:49 GMT RE: WCF RIA Services Part 3: Updating Data <p>i have datagrid say for employee table on silverligt page1.</p> <p>datagrid have one hyperlink button column say for empid.</p> <p>on click of that it opens child form where it displays that particular record in child form but in Details view instead of datagrid.</p> <p>on child form i have one save button.</p> <p>on click of save button i want to update the changes that i have made in the record.</p> <p>i hv written following code on save button click</p> <span style="font-family: consolas; font-size: 13px; color: #0000ff;"> <p>private <span style="font-family: consolas; font-size: 13px; color: #0000ff;">void</span><span style="font-family: consolas; font-size: 13px; color: #000000;"> btnSaveHRMS_Click(</span><span style="font-family: consolas; font-size: 13px; color: #0000ff;">object</span><span style="font-family: consolas; font-size: 13px; color: #000000;"> sender, </span><span style="font-family: consolas; font-size: 13px; color: #2b91af;">RoutedEventArgs)</span><span style="font-family: consolas; font-size: 2px; color: #000000;"><br /> </span><span style="font-family: 'times new roman'; font-size: medium; color: #000000;">{<br /> </span><span style="font-family: 'times new roman'; font-size: medium; color: #000000;">   context.SubmitChanges();<br /> </span><span style="font-family: 'times new roman'; font-size: medium; color: #000000;">}</span></p> </span> <p>code is not giving any compilation error.But it is not saving the changes in database table.</p> <p>If i write the same code fro saving the changes on master form itself then the code works fine and save the changes in database.</p> <p>Could you pls tell me why it is not saving changes from child form?</p> <p>Thanks.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4894 Silver123 http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 18 Nov 2010 12:51:03 GMT RE: WCF RIA Services Part 3: Updating Data Ted, I can put it on my ToDo list for a future blog post, but not something I can get to at the moment. http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4767 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 28 Oct 2010 00:54:12 GMT RE: WCF RIA Services Part 3: Updating Data Brian,  You replied to John saying " If you assign the child entity via an object reference, AND (important requirement, taken care of by Entity Framework but if not using that you would have to do yourself) decorate the parent entity properties with the Association and Include attributes, then it should all just work with a single SubmitChanges because of the change tracking information that is maintained by the DomainContext and its ability to merge the returned entities with the ones that the client side knows about."  Could you flesh this out, perhaps with an example or pointing to a resource that shows how to do this?  I have a rather complex DB with lots of foreign keys, one ot many and many to many relations.  Does that mean I have to have a suite of classes, each of which has a collection of child objcts? http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4766 Ted http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 28 Oct 2010 00:44:56 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hey Brian, </p> <p>You are doing a wonderful job here. I have tried updating data in an SQL database from a silverlight application and it has been giving me loads of issues but when i followed your approach it worked seamlessly. Please I will appreciate it if you could help with a tutorial that deals with communication between a silverlight application and SQL database across domains i.e on a different computer on the internet.</p> <p><br /> </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4704 Mobo http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Tue, 19 Oct 2010 04:18:13 GMT RE: WCF RIA Services Part 3: Updating Data <p>James and Alvin:</p> <p>myDomanContext.SomeEntityCollection.Remove(someEntity);</p> <p>myDomainContext.SubmitChanges();</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4595 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 30 Sep 2010 23:05:55 GMT RE: WCF RIA Services Part 3: Updating Data Please show me how to delete a record. http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4594 James http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 30 Sep 2010 22:23:21 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hi Alvin, </p> <p>To delete records, you first execute a query to retrieve them to the client side. Then you Remove the objects from their corresponding collection on the domain context. Then call SubmitChanges. When the update batch executes on the back end, those entities removed from the client collection will be passed to the domain service delete method for that entity type for deletion. If you don't want to have to retrieve the record to the client first, you could expose an [Invoke] method (see Part 6 for more info on Invoke methods) to pass an ID down and have the domain service Invoke method execute the right query to delete the entity without first retrieving it.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4533 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 23 Sep 2010 15:25:59 GMT RE: WCF RIA Services Part 3: Updating Data How to Delete the data? http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4530 Alvin http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Thu, 23 Sep 2010 11:12:33 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hi Merrill,</p> <p>The data has to get into the DataContext from somewhere with some programmatic code, so you get it from there directly. In the case of RIA Services, as I described in Part 1&2, the loading of the data happens asynchronously. So even though you set the ItemsSource of an ItemsControl and/or set the DataContext to an entity collection exposed by the domain context and call Load, the entity collection does not get populated until the service call completes asynchronously. You can pass a callback delegate to the Load operation to be called when that async completion occurs, and that is your deterministic place to know when the data is there and you have programmatic access to it.</p> <p>HTH, Brian</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4254 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Wed, 18 Aug 2010 00:46:27 GMT RE: WCF RIA Services Part 3: Updating Data Have a stupid question, all on timing. I need data out of a data context when the page loads .. without any user intervention.<br /> Current process is to load data from data context then items source it to a data grid. Next step is to do a for each in the data context and creat an ienumerable. Every thing works fine, but only if I do a button click after the data grid has been item sourced. Is there some way i can do this without user intervention? http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4253 Merrill Marie http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Wed, 18 Aug 2010 00:34:44 GMT RE: WCF RIA Services Part 3: Updating Data <p>Frank,</p> <p>With RIA Services, it is just a matter of locating the item you want to work with in the entity collections managed by the domain context (i.e. Tasks in my examples so far) after having done a Load operation on the domain context, often by executing a LINQ query on the entity collection. Then modify the properties on that object and call SubmitChanges on the domain context. The entities never have to touch the UI. The code in the view model of the sample code for this article is doing exactly that. The fact that the view model happens to expose that entity collection for data binding is incidental.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4244 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Mon, 16 Aug 2010 14:26:44 GMT RE: WCF RIA Services Part 3: Updating Data <p>all of the tutorials i have seen link the datasource to a datagrid .. update the datagrid, and then submit changes .. is there some way you can forget the dadagrid .. link the datasource to a Inumerable collection, update the collection, and then submit the changes .. if can be done, a real simple example would be appreciated ..</p> <p>thanks for your help!</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4171 Frank http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sun, 08 Aug 2010 16:40:20 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hey Brian,</p> <p>Finally, this WCF RIA stuff is starting to sink in based on your articles.  Thanks for the effort and am anxiously awaiting the rest of the series.  Have been trying to get my head around MVVM, MEF and PRISM also.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4095 CyclingFoodmanPA http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 30 Jul 2010 20:08:19 GMT RE: WCF RIA Services Part 3: Updating Data <p>So far so good.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4072 Andy http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Tue, 27 Jul 2010 20:12:53 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hello Brian</p> <p>Great articles so far. Really looking forward to the next ones in the series. Thanks!</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment4064 Matt http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Tue, 27 Jul 2010 01:41:26 GMT RE: WCF RIA Services Part 3: Updating Data <p>Thanks to both of you for your help. Cool feature.<br /> Also for now, it seems to me, that the relation is working just with using the include attribute. relation does not seem to add anything to the game...</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3972 Jonx http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sun, 11 Jul 2010 05:52:10 GMT RE: WCF RIA Services Part 3: Updating Data Many thanks for this article, it was what I was looking for. http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3958 Compuanalisis http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Fri, 09 Jul 2010 04:20:06 GMT RE: WCF RIA Services Part 3: Updating Data <p>Hi Sharad,</p> <p>Unfortunately the wizard is currently a one time opportunity, there is no way to get back into it if you don't select what you want the first time. My workaround to that is not to delete the class for the reason you mention - you might have made numerous customizations by that point and you would lose them. I just add a new domain service, say DomainService1, and select the same entities but check the edit box. You can then cut and paste the new insert/update/delete methods into the old class and delete the new one.</p> <p>You can certainly separate your domain service class into partial classes, but it won't really buy you anything since the code generation for the domain service is a one time thing.</p> <p>Hope that helps</p> <p>Brian</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3935 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Wed, 07 Jul 2010 06:25:54 GMT RE: WCF RIA Services Part 3: Updating Data <p>Thanks for this great series for beginners..i have been struggling to step into Silverlight for some time now...i come from the big fat windows world..your work is really helping me to get to grips ..i have couple of questions..i followed your part 1 and did not click on 'Enable Editing'.. for  part 2 the only way I could get the 'Enable Editing' was to delete the TaskDomainService class and recreate it again with the option checked..</p> <p>Q: Is there any other way of doing this...running any custom tool etc</p> <p>Secondly, as par part 1, I wrote the GetTasksByStartDate in the TasksDomainService class. Deleting this class meant I would loose my custom methods...This time i manage to copy and paste it again ...</p> <p>Q: Is there any way I could put my custom code in a partial class, so won't have to worry about loosing my code in future.</p> <p>Appreciate your work!</p> <p><br /> </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3931 Sharad http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Wed, 07 Jul 2010 02:58:35 GMT RE: WCF RIA Services Part 3: Updating Data <p>Nen is correct. If you assign the child entity via an object reference, AND (important requirement, taken care of by Entity Framework but if not using that you would have to do yourself) decorate the parent entity properties with the Association and Include attributes, then it should all just work with a single SubmitChanges because of the change tracking information that is maintained by the DomainContext and its ability to merge the returned entities with the ones that the client side knows about.</p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3909 Brian Noyes http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 03 Jul 2010 16:49:18 GMT RE: WCF RIA Services Part 3: Updating Data <p>John,</p> <p>if i am correct, you dont need to submit changes twice, all you need to do is, create a Project entity and then assign the task entitties project property to the project entity created above, EF will take care of the rest.</p> <p>Example:</p> <p> Project prj=new Project();</p> <p>Taks tsk =new Task();</p> <p>tsk.Project=prj;</p> <p>context.SubmitChanges</p> <p> </p> <p> </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3908 Nen http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 03 Jul 2010 15:29:57 GMT RE: WCF RIA Services Part 3: Updating Data <p>Great - Thanks </p> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3907 talu http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Sat, 03 Jul 2010 12:59:09 GMT RE: WCF RIA Services Part 3: Updating Data Hello, <div>very nice series of articles. Clear and smooth to read and understand. Thanks.</div> <div><br /> </div> <div>Now, what I don't get is how I create a parent and it's child at once? Because it run's async I'm in trouble, right?</div> <div><br /> </div> <div>If for example I wanted to create a new project with some tasks already in it...</div> <div>I create a new project but have no project id until I use submit changes. That means I can add the "default" tasks only after the completed returns? Do I need to do this server side? Is the domain service InsertProject the good place to add linked items? Is this also running async? When I add some stuff in the InsertProject I have the same problem. Things are not created until after someone called SubmitChanges... I'm lost...</div> <div><br /> </div> <div>Any hints on that? Thanks...</div> <div>John.</div> http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx#comment3886 Jonx http://www.silverlightshow.net/items/WCF-RIA-Services-Part-3-Updating-Data.aspx Tue, 29 Jun 2010 04:21:52 GMT