Transactions in IDBConnection

main
Inga 🏳‍🌈 14 years ago
parent d5f24d33ba
commit 7542f5737d
  1. 10
      Core/DB/IDBConnection.cs
  2. 41
      Core/DB/ITransaction.cs

@ -11,13 +11,15 @@ namespace FLocal.Core.DB {
int[] LoadIdsByConditions(ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts);
ILock lockTable(ITableSpec table);
Transaction beginTransaction();
ILock lockRow(ITableSpec table, int id);
ILock lockTable(Transaction transaction, ITableSpec table);
void update(ITableSpec table, int id, Dictionary<string, string> data);
ILock lockRow(Transaction transaction, ITableSpec table, int id);
void delete(ITableSpec table, int id); //do we really need this?
void update(Transaction transaction, ITableSpec table, int id, Dictionary<string, string> data);
void delete(Transaction transaction, ITableSpec table, int id); //do we really need this?
}

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLocal.Core.DB {
abstract class Transaction : IDisposable {
abstract protected void do_Commit();
abstract protected void do_Rollback();
private bool finalized = false;
public void Commit() {
lock(this) {
this.do_Commit();
this.finalized = true;
}
}
public void Rollback() {
lock(this) {
this.do_Rollback();
this.finalized = true;
}
}
public void Dispose() {
lock(this) {
if(!this.finalized) {
this.do_Rollback();
this.finalized = true;
}
}
}
}
}
Loading…
Cancel
Save