-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathCacheCommand.output.netfx.cs
More file actions
254 lines (210 loc) · 13.2 KB
/
CacheCommand.output.netfx.cs
File metadata and controls
254 lines (210 loc) · 13.2 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#nullable enable
#pragma warning disable IDE0078 // unnecessary suppression is necessary
#pragma warning disable CS9270 // SDK-dependent change to interceptors usage
namespace Dapper.AOT // interceptors must be in a known namespace
{
file static class DapperGeneratedInterceptors
{
[global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 15, 24)]
internal static int Execute0(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType)
{
// Execute, HasParameters, Text, CacheCommand, KnownParameters
// takes parameter: <anonymous type: int id, string bar>
// parameter map: bar id
global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql));
global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text);
global::System.Diagnostics.Debug.Assert(param is not null);
return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory0.Instance0).Execute(param);
}
[global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 16, 24)]
internal static int Execute1(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType)
{
// Execute, HasParameters, Text, CacheCommand, KnownParameters
// takes parameter: <anonymous type: int id, string bar>
// parameter map: bar id
global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql));
global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text);
global::System.Diagnostics.Debug.Assert(param is not null);
return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory0.Instance1).Execute(param);
}
[global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 19, 24)]
internal static int Execute2(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType)
{
// Execute, HasParameters, Text, CacheCommand, KnownParameters
// takes parameter: <anonymous type: int id, string bar>
// parameter map: id
global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql));
global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text);
global::System.Diagnostics.Debug.Assert(param is not null);
return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory1.Instance0).Execute(param);
}
[global::System.Runtime.CompilerServices.InterceptsLocationAttribute("Interceptors\\CacheCommand.input.cs", 22, 24)]
internal static int Execute3(this global::System.Data.IDbConnection cnn, string sql, object? param, global::System.Data.IDbTransaction? transaction, int? commandTimeout, global::System.Data.CommandType? commandType)
{
// Execute, HasParameters, Text, KnownParameters
// takes parameter: <anonymous type: int id, string bar>
// parameter map: (deferred)
global::System.Diagnostics.Debug.Assert(!string.IsNullOrWhiteSpace(sql));
global::System.Diagnostics.Debug.Assert((commandType ?? global::Dapper.DapperAotExtensions.GetCommandType(sql)) == global::System.Data.CommandType.Text);
global::System.Diagnostics.Debug.Assert(param is not null);
return global::Dapper.DapperAotExtensions.Command(cnn, transaction, sql, global::System.Data.CommandType.Text, commandTimeout.GetValueOrDefault(), CommandFactory2.Instance).Execute(param);
}
private class CommonCommandFactory<T> : global::Dapper.CommandFactory<T>
{
public override global::System.Data.Common.DbCommand GetCommand(global::System.Data.Common.DbConnection connection, string sql, global::System.Data.CommandType commandType, T args)
{
var cmd = base.GetCommand(connection, sql, commandType, args);
// apply special per-provider command initialization logic for OracleCommand
if (cmd is global::Oracle.ManagedDataAccess.Client.OracleCommand cmd0)
{
cmd0.BindByName = true;
cmd0.InitialLONGFetchSize = -1;
}
return cmd;
}
}
private static readonly CommonCommandFactory<object?> DefaultCommandFactory = new();
private abstract class CommandFactory0 : CommonCommandFactory<object?> // <anonymous type: int id, string bar>
{
// these represent different call-sites (and most likely all have different SQL etc)
internal static readonly CommandFactory0.Cached0 Instance0 = new();
internal static readonly CommandFactory0.Cached1 Instance1 = new();
public override void AddParameters(in global::Dapper.UnifiedCommand cmd, object? args)
{
var typed = Cast(args, static () => new { id = default(int), bar = default(string)! }); // expected shape
var ps = cmd.Parameters;
global::System.Data.Common.DbParameter p;
p = cmd.CreateParameter();
p.ParameterName = "id";
p.DbType = global::System.Data.DbType.Int32;
p.Direction = global::System.Data.ParameterDirection.Input;
p.Value = AsValue(typed.id);
ps.Add(p);
p = cmd.CreateParameter();
p.ParameterName = "bar";
p.DbType = global::System.Data.DbType.String;
p.Direction = global::System.Data.ParameterDirection.Input;
SetValueWithDefaultSize(p, typed.bar);
ps.Add(p);
}
public override void UpdateParameters(in global::Dapper.UnifiedCommand cmd, object? args)
{
var typed = Cast(args, static () => new { id = default(int), bar = default(string)! }); // expected shape
var ps = cmd.Parameters;
ps[0].Value = AsValue(typed.id);
ps[1].Value = AsValue(typed.bar);
}
public override bool CanPrepare => true;
public override global::System.Data.Common.DbCommand GetCommand(global::System.Data.Common.DbConnection connection,
string sql, global::System.Data.CommandType commandType, object? args)
=> TryReuseThreadStatic(ref Storage, sql, commandType, args, _cmdPool) ?? base.GetCommand(connection, sql, commandType, args);
public override bool TryRecycle(global::System.Data.Common.DbCommand command) => TryRecycleThreadStatic(ref Storage, command, _cmdPool);
private readonly DbCommandCache _cmdPool = new(); // note: per cache instance
protected abstract ref global::System.Data.Common.DbCommand? Storage {get;}
internal sealed class Cached0 : CommandFactory0
{
protected override ref global::System.Data.Common.DbCommand? Storage => ref s_Storage;
[global::System.ThreadStatic] // note this works correctly with ref-return
private static global::System.Data.Common.DbCommand? s_Storage;
}
internal sealed class Cached1 : CommandFactory0
{
protected override ref global::System.Data.Common.DbCommand? Storage => ref s_Storage;
[global::System.ThreadStatic] // note this works correctly with ref-return
private static global::System.Data.Common.DbCommand? s_Storage;
}
}
private sealed class CommandFactory1 : CommonCommandFactory<object?> // <anonymous type: int id, string bar>
{
internal static readonly CommandFactory1 Instance0 = new();
public override void AddParameters(in global::Dapper.UnifiedCommand cmd, object? args)
{
var typed = Cast(args, static () => new { id = default(int), bar = default(string)! }); // expected shape
var ps = cmd.Parameters;
global::System.Data.Common.DbParameter p;
p = cmd.CreateParameter();
p.ParameterName = "id";
p.DbType = global::System.Data.DbType.Int32;
p.Direction = global::System.Data.ParameterDirection.Input;
p.Value = AsValue(typed.id);
ps.Add(p);
}
public override void UpdateParameters(in global::Dapper.UnifiedCommand cmd, object? args)
{
var typed = Cast(args, static () => new { id = default(int), bar = default(string)! }); // expected shape
var ps = cmd.Parameters;
ps[0].Value = AsValue(typed.id);
}
public override bool CanPrepare => true;
public override global::System.Data.Common.DbCommand GetCommand(global::System.Data.Common.DbConnection connection,
string sql, global::System.Data.CommandType commandType, object? args)
=> TryReuseThreadStatic(ref Storage, sql, commandType, args, _cmdPool) ?? base.GetCommand(connection, sql, commandType, args);
public override bool TryRecycle(global::System.Data.Common.DbCommand command) => TryRecycleThreadStatic(ref Storage, command, _cmdPool);
private static readonly DbCommandCache _cmdPool = new();
[global::System.ThreadStatic] // note this works correctly with ref
private static global::System.Data.Common.DbCommand? Storage;
}
private sealed class CommandFactory2 : CommonCommandFactory<object?> // <anonymous type: int id, string bar>
{
internal static readonly CommandFactory2 Instance = new();
public override void AddParameters(in global::Dapper.UnifiedCommand cmd, object? args)
{
var typed = Cast(args, static () => new { id = default(int), bar = default(string)! }); // expected shape
var ps = cmd.Parameters;
global::System.Data.Common.DbParameter p;
var sql = cmd.CommandText;
var commandType = cmd.CommandType;
if (Include(sql, commandType, "id"))
{
p = cmd.CreateParameter();
p.ParameterName = "id";
p.DbType = global::System.Data.DbType.Int32;
p.Direction = global::System.Data.ParameterDirection.Input;
p.Value = AsValue(typed.id);
ps.Add(p);
}
if (Include(sql, commandType, "bar"))
{
p = cmd.CreateParameter();
p.ParameterName = "bar";
p.DbType = global::System.Data.DbType.String;
p.Direction = global::System.Data.ParameterDirection.Input;
SetValueWithDefaultSize(p, typed.bar);
ps.Add(p);
}
}
public override void UpdateParameters(in global::Dapper.UnifiedCommand cmd, object? args)
{
var typed = Cast(args, static () => new { id = default(int), bar = default(string)! }); // expected shape
var ps = cmd.Parameters;
var sql = cmd.CommandText;
var commandType = cmd.CommandType;
if (Include(sql, commandType, "id"))
{
ps["id"].Value = AsValue(typed.id);
}
if (Include(sql, commandType, "bar"))
{
ps["bar"].Value = AsValue(typed.bar);
}
}
public override bool CanPrepare => true;
}
}
}
namespace System.Runtime.CompilerServices
{
// this type is needed by the compiler to implement interceptors - it doesn't need to
// come from the runtime itself, though
[global::System.Diagnostics.Conditional("DEBUG")] // not needed post-build, so: evaporate
[global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = true)]
sealed file class InterceptsLocationAttribute : global::System.Attribute
{
public InterceptsLocationAttribute(string path, int lineNumber, int columnNumber)
{
_ = path;
_ = lineNumber;
_ = columnNumber;
}
}
}