Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/ContextFactory.cs @ 4073

Last change on this file since 4073 was 4073, checked in by cneumuel, 14 years ago

moved remaining Hive projects to 3.3-HiveMigration (#1091)

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Data.Common;
6using System.Data.SqlClient;
7using HeuristicLab.Tracing;
8
9namespace HeuristicLab.Hive.Server.LINQDataAccess {
10  public class ContextFactory {
11    [ThreadStatic]
12    private static HiveDataContext _hiveDataContext = null;
13
14    [ThreadStatic]
15    private static SqlTransaction _currentTransaction = null;
16
17    public static HiveDataContext Context {
18      get {
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;Integrated Security=SSPI");
22          _hiveDataContext.CommandTimeout = 240;
23        }
24        return _hiveDataContext;       
25      }
26      set {       
27        _hiveDataContext = value;
28      }
29    }
30
31    public static SqlTransaction CurrentTransaction {
32      get {
33        return _currentTransaction;
34      } set {
35        _currentTransaction = value;
36      }
37    }
38
39    public static bool IsContextNull() {
40      return _hiveDataContext == null;
41    }
42  }
43}
Note: See TracBrowser for help on using the repository browser.