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
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.Linq.Test;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.