DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
TransactionContextExtensions.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 
19 using Deveel.Data.Sql;
20 using Deveel.Data.Sql.Variables;
21 
22 namespace Deveel.Data.Transactions {
23  public static class TransactionContextExtensions {
24  #region Variables
25 
26  public static bool IgnoreIdentifiersCase(this ITransactionContext transaction) {
27  return transaction.GetBooleanVariable(TransactionSettingKeys.IgnoreIdentifiersCase);
28  }
29 
30  public static void IgnoreIdentifiersCase(this ITransactionContext transaction, bool value) {
31  transaction.SetBooleanVariable(TransactionSettingKeys.IgnoreIdentifiersCase, value);
32  }
33 
34  public static bool ReadOnly(this ITransactionContext transaction) {
35  return transaction.GetBooleanVariable(TransactionSettingKeys.ReadOnly);
36  }
37 
38  public static void ReadOnly(this ITransactionContext transaction, bool value) {
39  transaction.SetBooleanVariable(TransactionSettingKeys.ReadOnly, value);
40  }
41 
42  public static bool AutoCommit(this ITransactionContext transaction) {
43  return transaction.GetBooleanVariable(TransactionSettingKeys.AutoCommit);
44  }
45 
46  public static void AutoCommit(this ITransactionContext transaction, bool value) {
47  transaction.SetBooleanVariable(TransactionSettingKeys.AutoCommit, value);
48  }
49 
50  public static void CurrentSchema(this ITransactionContext transaction, string schemaName) {
51  transaction.SetStringVariable(TransactionSettingKeys.CurrentSchema, schemaName);
52  }
53 
54  public static string CurrentSchema(this ITransactionContext transaction) {
55  return transaction.GetStringVariable(TransactionSettingKeys.CurrentSchema);
56  }
57 
58  public static bool ErrorOnDirtySelect(this ITransactionContext transaction) {
59  return transaction.GetBooleanVariable(TransactionSettingKeys.ErrorOnDirtySelect);
60  }
61 
62  public static void ErrorOnDirtySelect(this ITransactionContext transaction, bool value) {
63  transaction.SetBooleanVariable(TransactionSettingKeys.ErrorOnDirtySelect, value);
64  }
65 
66  public static QueryParameterStyle ParameterStyle(this ITransactionContext transaction) {
67  var styleString = transaction.GetStringVariable(TransactionSettingKeys.ParameterStyle);
68  if (String.IsNullOrEmpty(styleString))
69  return QueryParameterStyle.Default;
70 
71  return (QueryParameterStyle)Enum.Parse(typeof(QueryParameterStyle), styleString, true);
72  }
73 
74  public static void ParameterStyle(this ITransactionContext transaction, QueryParameterStyle value) {
75  if (value == QueryParameterStyle.Default)
76  return;
77 
78  var styleString = value.ToString();
79  transaction.SetStringVariable(TransactionSettingKeys.ParameterStyle, styleString);
80  }
81 
82  public static void ParameterStyle(this ITransactionContext transaction, string value) {
83  if (String.IsNullOrEmpty(value))
84  throw new ArgumentNullException("value");
85 
86  var style = (QueryParameterStyle)Enum.Parse(typeof(QueryParameterStyle), value, true);
87  transaction.ParameterStyle(style);
88  }
89 
90  #endregion
91  }
92 }
static void CurrentSchema(this ITransactionContext transaction, string schemaName)
static bool ReadOnly(this ITransactionContext transaction)
static void ParameterStyle(this ITransactionContext transaction, QueryParameterStyle value)
static string CurrentSchema(this ITransactionContext transaction)
static void ParameterStyle(this ITransactionContext transaction, string value)
static QueryParameterStyle ParameterStyle(this ITransactionContext transaction)
static bool IgnoreIdentifiersCase(this ITransactionContext transaction)
static bool AutoCommit(this ITransactionContext transaction)
QueryParameterStyle
In a SQL query object, this is the form of parameters passed from the client side to the server side...
static void ReadOnly(this ITransactionContext transaction, bool value)
static void AutoCommit(this ITransactionContext transaction, bool value)
static void ErrorOnDirtySelect(this ITransactionContext transaction, bool value)
static void IgnoreIdentifiersCase(this ITransactionContext transaction, bool value)
static bool ErrorOnDirtySelect(this ITransactionContext transaction)