This forum is used by the Opf3 developers to announce new features or to discuss with you about ideas on new features.
 | |
| | Version 3.0.9.x introduces a new class with name "Transaction". This clas is returned by the ObjectContext when calling StartTransaction (if the ObjectContext was able to start a transaction on the storage, otherwise null).
The Transaction class implements the IDisposable interface, which allows you to use the C# or VB.NET "using" statement:
User u2 = new User(); u2.IsAdministrator = true; u2.LastLogin = DateTime.Now; u2.Username = "Foo";
try { // Putting the start of the transaction in a using statement // makes sure that the transaction is automatically rolled // back if not committed (when leaving the using block). using (Transaction t = context.StartTransaction()) { // Try to save the user. context.PersistChanges(u2);
// Commit the transaction here. The object was saved // properly (no exception thrown). t.Commit(); } } catch (StorageException ex) { // We got an exception (the transaction is already // rolled back at this stage) and show it to the user. Console.WriteLine("Error during save" + ex.Message); }
This new class makes the code easier to read and avoids problems with forgetting to roll back a transaction.
Regards, Christian
|
 | |
| | Ok cool future .. but old syntax work with new ?? When new version opf3 come to us ?? :D
GOOD WORK Christian
|
 | |
| | Hi,
both versions work. Although I'm thinking to mark the old commit and rollback as obsolete. What does everybody else think? Should they stay or be marked as obsolete?
|
 | |
| | Hello,
Just wondering what would be the best practice to handle transaction using Opf3 if the application needs to deal with multiple storages?
Have you tested Opf3 with .NET 2.0 System.Transactions? We have a 3rd party application which we do not have direct access to the SQL server, instead, we will need to call its APIs to make changes to the data. I'm thinking of using .NET 2.0 System Transactions, but havn't had the time to test it yet.
Thanks
Marvin
|
 | |
| | Hi Marv,
Opf3 isn't tested with them. We had not time so far to test them with .NET 2.0 Transactions.
Regards, Christian
|