Visual Studio and .NET Framework Home
Change to LINQ to SQL EntitySet Member Doesn't Mark Root Object Dirty
as By Design
10/19/2007 12:49:59 PM
User(s) can reproduce this bug
In a LINQ to SQL test harness with DataGridViews bound through a BindingSource to a DataContext with, for this example, a Northwind Customer entity and its eager-loaded Orders and Order_Details entity sets, making a change to a Customer (root) member's value marks the object dirty (i.e., it returns an object to the ctx.GetChanges<Customer>() method.)
Changing the value of a member of Orders or Order_Details entity sets in the corresponding DataGridView controls doesn't set the object dirty (i.e., the List<Customer> returned by the ctx.GetChanges<Customer>() method has a .Count of 0.
The workaround for this problem is a hack to change a Customer field value by, for example, adding a space to Customer.ContactName, then removing it in the WCF service. However, the issue isn't specific to SOA.
(This problem doesn't appear to be identical to that of https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=295116)
For more background on the problem, see the "Adding Missing Orders and Order_Details EntitySets to Original Values" topic of http://oakleafblog.blogspot.com/2007/10/linq-to-sql-has-no-multi-tier-story.html.
Visual Studio Code Name "Orcas" (Beta 2)
Operating System Language
Steps to Reproduce
1. Create a test harness to a NorthwindDataContext with Customer, Order, and Order_Detail types, drag the Customer node to the form, then drag the Customer.Order and customer.Order.Details nodes to generate three DataGridViews and BindingSources.
2. Eager-load the Order and Order_Detail Entity sets.
3. Add an event handler to the CurrentCellDirtyContentChanged of the Order and Order_Detail DataGridViews with code like this:
private void order_DetailsDataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
List<Customer> custChanges = ctx.GetChanged<Customer>();
if (custChanges.Count == 0)
// Hack to set the Customer object dirty
customerDataGridView.CurrentRow.Cells.Value += " ";
4. Change a Order.member value.
Code in the if block executes because Count == 0
Code in the if block not to execute because Count == 1
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 10/23/2007 at 7:14 PM
Thanks for reporting this issue you've encountered with Visual Studio 2008!
We've reproduced the issue you've submitted, but only before you press Enter on that row.
Each time a letter is added or removed from a column value, the CurrentCellDirtyStateChanged event is triggered, but the value returned by DataContext.GetChangeSet.Count is still 0. When this modification is actually committed by hitting Enter, the event is triggered again, but the DataContext.GetChangeSet.Count is now 1.
We therefore believe the behavior you experienced is By Design, but if the Count is still not 1 for you after hitting Enter, please reactivate this bug and let us know!
to post a workaround.
Please enter a workaround.
© 2014 Microsoft