Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB, C#, and VFP data handling examples
Message
From
26/04/2007 09:23:32
 
 
To
25/04/2007 23:13:00
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
01215120
Message ID:
01220097
Views:
34
John!

>I'm not sure what do you mean with "if you disconnect from the data".
>
>I'm talking about "Linq to SQL" entities - i.e. the dLinq that VFP people have been told will deliver what they want. I guess it's confusing unless I say "Linq to SQL" every time, but it's a real mouthful. Or maybe I should talk about passing around "objects".

Know what! I get a way to handle individual fields in DLinq, after all! :)

It is not absolutely automatic, but it is something you can make into a reusable piece in 5 minutes.

Here is it:
try {
   context.SubmitChanges(ConflictMode.ContinueOnConflict);
}
catch (OptimisticConcurrencyException e) {
   foreach (OptimisticConcurrencyConflict conflict in e.Conflicts) {
      conflict.Resolve(RefreshMode.KeepChanges);
   }
}
A few details here:
SubmitChanges accepts this ConflictMode parameter for optimistic concurrency control, where the enum options are:

FailOnFirstConflict or ContinueOnConflict

The first will throw the conflict exception as soon as it founds something, the second will go on and return all the conflicts into the exception, so you can check them.

In the Try/Catch I'm iterating the conflict list and calling the Resolve method that let me:
KeepChanges - sending only my CHANGES only to the DB
KeepCurrentValues - forcing my CURRENT values (even what I didn't changed)
OverwriteCurrentValues - giving up on the changes and getting what's on the DB (no change)

To get it clear, notice that this is all written from the client perspective. When you say keep or overwrite, you are talking about what it will end up with your version of the object (and the DB will get in synch).

Now, oing back to what you said about "disconnect from the data", even Linq works in a disconnected fashion. You can lose change tracking depending on how you pass your results from the data tier up, because you can't return the IEnumerable returned directly. This is so because this return value doesn't actually hold any data, but it is just an Iterator. You get the data when you Iterate it (with a foreach, etc).

Hope this helps, and I guess it will create a lot of additional questions. I have a coupe busy days ahead, but I'll try to monitor this thread as often as I can.

Regards,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform