Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2095


Ignore:
Timestamp:
06/25/09 12:48:29 (15 years ago)
Author:
svonolfe
Message:

Updated SessionFactory (#372)

Location:
trunk/sources/HeuristicLab.DataAccess.ADOHelper/3.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataAccess.ADOHelper/3.2/Session.cs

    r1529 r2095  
    4242    private Thread ownerThread;
    4343
     44    private int counter;
     45
    4446    private IDictionary<Guid, object> adapters =
    4547      new Dictionary<Guid, object>();
     
    4850      this.factory = factory;
    4951      this.ownerThread = Thread.CurrentThread;
     52      this.counter = 0;
    5053    }
    5154
     
    6871    public void DetachTrasaction() {
    6972      this.transaction = null;
     73    }
     74
     75    public void IncrementCounter() {
     76      this.counter++;
    7077    }
    7178
     
    127134
    128135    public void EndSession() {
    129       CheckThread();
     136      this.counter--;
    130137
    131       if (transaction != null) {
    132         transaction.Rollback();
    133         transaction = null;
     138      if (counter <= 0) {
     139        CheckThread();
     140
     141        if (transaction != null) {
     142          transaction.Rollback();
     143          transaction = null;
     144        }
     145        if (connection.State == System.Data.ConnectionState.Open) {
     146          connection.Close();
     147          connection = null;
     148        }
     149        factory.EndSession(this);
    134150      }
    135       if (connection.State == System.Data.ConnectionState.Open) {
    136         connection.Close();
    137         connection = null;
    138       }
    139       factory.EndSession(this);
    140151    }
    141152
  • trunk/sources/HeuristicLab.DataAccess.ADOHelper/3.2/SessionFactory.cs

    r1529 r2095  
    3131namespace HeuristicLab.DataAccess.ADOHelper {
    3232  public class SessionFactory: ISessionFactory {
    33     private IDictionary<Thread, ISession> sessions =
    34       new Dictionary<Thread, ISession>();
     33    private IDictionary<Thread, Session> sessions =
     34      new Dictionary<Thread, Session>();
    3535
    3636    public Type DbConnectionType { get;  set; }
     
    8686        }
    8787
     88        sessions[current].IncrementCounter();
     89
    8890        return sessions[current];
    8991      }
Note: See TracChangeset for help on using the changeset viewer.