forked from ServiceStack/ServiceStack.OrmLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOracleCommand.cs
More file actions
137 lines (115 loc) · 3.66 KB
/
Copy pathOracleCommand.cs
File metadata and controls
137 lines (115 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Data;
using System.Data.Common;
using System.Reflection;
namespace ServiceStack.OrmLite.Oracle
{
public class OracleCommand : DbCommand
{
private readonly DbCommand _command;
private readonly Lazy<MethodInfo> _setBindByNameMethod;
private bool _bindByNameIsSet;
public OracleCommand(DbCommand command)
{
if (command == null)
throw new ArgumentNullException("command");
_command = command;
_setBindByNameMethod = new Lazy<MethodInfo>(() => InitSetBindByName(_command));
}
private static MethodInfo InitSetBindByName(DbCommand command)
{
return command.GetType().GetMethod("set_BindByName", BindingFlags.Public | BindingFlags.Instance);
}
private MethodInfo SetBindByNameMethod
{
get
{
return _setBindByNameMethod.Value;
}
}
private void SetBindByName()
{
if (_bindByNameIsSet || SetBindByNameMethod == null) return;
SetBindByNameMethod.Invoke(_command, new object[] { true });
_bindByNameIsSet = true;
}
public override void Prepare()
{
_command.Prepare();
}
public override string CommandText
{
get { return _command.CommandText; }
set { _command.CommandText = value; }
}
public override int CommandTimeout
{
get { return _command.CommandTimeout; }
set { _command.CommandTimeout = value; }
}
public override CommandType CommandType
{
get { return _command.CommandType; }
set { _command.CommandType = value; }
}
protected override DbConnection DbConnection
{
get { return _command.Connection; }
set
{
_command.Connection = value;
}
}
protected override DbParameterCollection DbParameterCollection
{
get { return _command.Parameters; }
}
protected override DbTransaction DbTransaction
{
get { return _command.Transaction; }
set { _command.Transaction = value; }
}
public override bool DesignTimeVisible
{
get { return _command.DesignTimeVisible; }
set { _command.DesignTimeVisible = value; }
}
public override UpdateRowSource UpdatedRowSource
{
get { return _command.UpdatedRowSource; }
set { _command.UpdatedRowSource = value; }
}
public override void Cancel()
{
_command.Cancel();
}
protected override DbParameter CreateDbParameter()
{
return _command.CreateParameter();
}
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
{
if (Parameters.Count > 0) SetBindByName();
var reader = _command.ExecuteReader(behavior);
return new OracleDataReader(reader);
}
public override int ExecuteNonQuery()
{
if (Parameters.Count > 0) SetBindByName();
return _command.ExecuteNonQuery();
}
public override object ExecuteScalar()
{
if (Parameters.Count > 0) SetBindByName();
return _command.ExecuteScalar();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
_command.Dispose();
}
base.Dispose(disposing);
}
}
}