Last change
on this file since 4593 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 | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Data.Common;
|
---|
6 | using System.Data.SqlClient;
|
---|
7 | using HeuristicLab.Tracing;
|
---|
8 |
|
---|
9 | namespace 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.