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
|
Rev | Line | |
---|
[2904] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
[3220] | 5 | using System.Data.Common;
|
---|
| 6 | using System.Data.SqlClient;
|
---|
[3931] | 7 | using HeuristicLab.Tracing;
|
---|
[2904] | 8 |
|
---|
| 9 | namespace 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.