Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs @ 15762

Last change on this file since 15762 was 3931, checked in by kgrading, 15 years ago

added minor speedups and better transaction handling to the server (#828)

File size: 1.2 KB
RevLine 
[2904]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
[3220]5using System.Data.Common;
6using System.Data.SqlClient;
[3931]7using HeuristicLab.Tracing;
[2904]8
9namespace HeuristicLab.Hive.Server.LINQDataAccess {
10  public class ContextFactory {
11    [ThreadStatic]
[3578]12    private static HiveDataContext _hiveDataContext = null;
[2904]13
[3220]14    [ThreadStatic]
[3578]15    private static SqlTransaction _currentTransaction = null;
[3220]16
[2904]17    public static HiveDataContext Context {
18      get {
[3931]19        if (_hiveDataContext == null) {
20          Logger.Debug("Requested new Data Context");
21          _hiveDataContext = new HiveDataContext("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq.Test;Integrated Security=SSPI");
22          _hiveDataContext.CommandTimeout = 240;
23        }
[2904]24        return _hiveDataContext;       
25      }
[3220]26      set {       
[3011]27        _hiveDataContext = value;
28      }
[2904]29    }
[3220]30
31    public static SqlTransaction CurrentTransaction {
32      get {
33        return _currentTransaction;
34      } set {
35        _currentTransaction = value;
36      }
37    }
[3931]38
39    public static bool IsContextNull() {
40      return _hiveDataContext == null;
41    }
[2904]42  }
43}
Note: See TracBrowser for help on using the repository browser.