-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Client Side Question) Merge fresh Order from DB in a ChangeTrackingCollection<Order> #154
Comments
Have you tried the For an example, see the Program.Main in the Console client for any of the samples. Does this address your question? |
I'm trying to reproduce the scenario where in a multi-user environment another user updates data.
//Go to sql server and add or delete a child relationship. The refresh order will be the current unstale version.
//This does not refresh the Order in the list of _orders. _orders[0] still has 2 OrderDetails, while _refreshOrder has 3. |
So here is now Assuming that |
Ok, that's how I assumed mergechanges() worked but it wasn't refreshing the ChangeCollection. I was using your samples to produce the issue. If I have time Monday I'll give more details. Enjoy the weekend. |
Here is a screen cast, let me know if that helps clarify. |
Terrific, I'll have a look. |
Great use of screen capture to demo an issue. I'll reproduce it on my end and have a look at what's going on. |
That's great, I'm glad that clarified the issue. Hopefully it's not just something I've coded incorrectly - I try to be mindful of people's time :) |
Added a failing test for this in PR #156. |
What is the proper way to update a ChangeTrackingCollection of Order when you want to merge a "fresh" Order that is fetched from the DB but you want to retain the same index of the existing order in the ChangeTrackingCollection.
var _order1 = //fetch from db
ChangeTrackingCollection _Orders = new ChangeTrackingCollection(order1 );
//Detect stale data, grab new value
var _neworder1 = //fetch from db;
_Orders[0] = _neworder1;
In the above approach tracking is turned off for the _neworder1 entity. You can do the following to turn it back on:
_Orders.Tracking = false;
_Orders.Tracking = true;
Is there a better way to do this? This approach would reset any pending changes you had on the client.
Is there something like a MergeFresh() that I'm overlooking? This method would take a "Fresh" Order and update tracking appropriately. For example, an Order has a Freight and Discount Property. Client Side both are changed from 1,1 to 2,2 respectively. Client detects there are changes from another user. Client finds that Freight has changed but Discount has not changed values on the DB are currently 3,1. Client MergeFresh() is called. It changes the state of Freight to Unchanged with a value of 3. It leaves the trackable state of Discount to Modified with a value of 2 because the Original value matches the DB value.
The text was updated successfully, but these errors were encountered: