/
OrmLiteWriteApiAsync.cs
447 lines (404 loc) · 23.6 KB
/
OrmLiteWriteApiAsync.cs
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
#if ASYNC
// Copyright (c) ServiceStack, Inc. All Rights Reserved.
// License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ServiceStack.Data;
using ServiceStack.Text;
namespace ServiceStack.OrmLite
{
public static class OrmLiteWriteApiAsync
{
/// <summary>
/// Execute any arbitrary raw SQL.
/// </summary>
/// <returns>number of rows affected</returns>
public static Task<int> ExecuteSqlAsync(this IDbConnection dbConn, string sql, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.ExecuteSqlAsync(sql, token));
}
/// <summary>
/// Execute any arbitrary raw SQL with db params.
/// </summary>
/// <returns>number of rows affected</returns>
public static Task<int> ExecuteSqlAsync(this IDbConnection dbConn, string sql, object dbParams, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.ExecuteSqlAsync(sql, dbParams, token));
}
/// <summary>
/// Insert 1 POCO, use selectIdentity to retrieve the last insert AutoIncrement id (if any). E.g:
/// <para>var id = db.Insert(new Person { Id = 1, FirstName = "Jimi }, selectIdentity:true)</para>
/// </summary>
public static Task<long> InsertAsync<T>(this IDbConnection dbConn, T obj, bool selectIdentity = false,
bool enableIdentityInsert =false,CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync(obj, commandFilter: null, selectIdentity: selectIdentity, enableIdentityInsert,token: token));
}
/// <summary>
/// Insert 1 POCO, use selectIdentity to retrieve the last insert AutoIncrement id (if any). E.g:
/// <para>var id = db.Insert(new Person { Id = 1, FirstName = "Jimi }, selectIdentity:true)</para>
/// </summary>
public static Task<long> InsertAsync<T>(this IDbConnection dbConn, T obj, Action<IDbCommand> commandFilter, bool selectIdentity = false, bool enableIdentityInsert = false, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync(obj, commandFilter: commandFilter, selectIdentity:selectIdentity, enableIdentityInsert, token:token));
}
/// <summary>
/// Insert 1 POCO, use selectIdentity to retrieve the last insert AutoIncrement id (if any). E.g:
/// <para>var id = db.Insert(new Dictionary<string,object> { ["Id"] = 1, ["FirstName"] = "Jimi }, selectIdentity:true)</para>
/// </summary>
public static Task<long> InsertAsync<T>(this IDbConnection dbConn, Dictionary<string,object> obj, bool selectIdentity = false, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync<T>(obj, commandFilter: null, selectIdentity:selectIdentity, token));
}
/// <summary>
/// Insert 1 POCO, use selectIdentity to retrieve the last insert AutoIncrement id (if any). E.g:
/// <para>var id = db.Insert(new Dictionary<string,object> { ["Id"] = 1, ["FirstName"] = "Jimi }, dbCmd => applyFilter(dbCmd))</para>
/// </summary>
public static Task<long> InsertAsync<T>(this IDbConnection dbConn, Action<IDbCommand> commandFilter,
Dictionary<string,object> obj, bool selectIdentity = false, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync<T>(obj, commandFilter: commandFilter, selectIdentity:selectIdentity, token));
}
/// <summary>
/// Insert 1 or more POCOs in a transaction. E.g:
/// <para>db.InsertAsync(new Person { Id = 1, FirstName = "Tupac", LastName = "Shakur", Age = 25 },</para>
/// <para> new Person { Id = 2, FirstName = "Biggie", LastName = "Smalls", Age = 24 })</para>
/// </summary>
public static Task InsertAsync<T>(this IDbConnection dbConn, CancellationToken token, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync(commandFilter:null, token:token, objs:objs));
}
public static Task InsertAsync<T>(this IDbConnection dbConn, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync(commandFilter:null, token:default, objs:objs));
}
/// <summary>
/// Insert 1 or more POCOs in a transaction and modify populated IDbCommand with a commandFilter. E.g:
/// <para>db.InsertAsync(dbCmd => applyFilter(dbCmd), token, </para>
/// <para> new Person { Id = 1, FirstName = "Tupac", LastName = "Shakur", Age = 25 },</para>
/// <para> new Person { Id = 2, FirstName = "Biggie", LastName = "Smalls", Age = 24 })</para>
/// </summary>
public static Task InsertAsync<T>(this IDbConnection dbConn, Action<IDbCommand> commandFilter, CancellationToken token, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAsync(commandFilter:commandFilter, token:token, objs:objs));
}
/// <summary>
/// Insert 1 or more POCOs in a transaction using Table default values when defined. E.g:
/// <para>db.InsertUsingDefaultsAsync(new Person { FirstName = "Tupac", LastName = "Shakur" },</para>
/// <para> new Person { FirstName = "Biggie", LastName = "Smalls" })</para>
/// </summary>
public static Task InsertUsingDefaultsAsync<T>(this IDbConnection dbConn, T[] objs, CancellationToken token=default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertUsingDefaultsAsync(objs, token));
}
/// <summary>
/// Insert results from SELECT SqlExpression, use selectIdentity to retrieve the last insert AutoIncrement id (if any). E.g:
/// <para>db.InsertIntoSelectAsync<Contact>(db.From<Person>().Select(x => new { x.Id, Surname == x.LastName }))</para>
/// </summary>
public static Task<long> InsertIntoSelectAsync<T>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token=default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertIntoSelectAsync<T>(query, commandFilter: null, token:token));
}
/// <summary>
/// Insert results from SELECT SqlExpression, use selectIdentity to retrieve the last insert AutoIncrement id (if any). E.g:
/// <para>db.InsertIntoSelectAsync<Contact>(db.From<Person>().Select(x => new { x.Id, Surname == x.LastName }))</para>
/// </summary>
public static Task<long> InsertIntoSelectAsync<T>(this IDbConnection dbConn, ISqlExpression query, Action<IDbCommand> commandFilter, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertIntoSelectAsync<T>(query, commandFilter: commandFilter, token:token));
}
/// <summary>
/// Insert a collection of POCOs in a transaction. E.g:
/// <para>db.InsertAllAsync(new[] { new Person { Id = 9, FirstName = "Biggie", LastName = "Smalls", Age = 24 } })</para>
/// </summary>
public static Task InsertAllAsync<T>(this IDbConnection dbConn, IEnumerable<T> objs, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAllAsync(objs, commandFilter:null, token:token));
}
/// <summary>
/// Insert a collection of POCOs in a transaction and modify populated IDbCommand with a commandFilter. E.g:
/// <para>db.InsertAllAsync(new[] { new Person { Id = 9, FirstName = "Biggie", LastName = "Smalls", Age = 24 } },</para>
/// <para> dbCmd => applyFilter(dbCmd))</para>
/// </summary>
public static Task InsertAllAsync<T>(this IDbConnection dbConn, IEnumerable<T> objs, Action<IDbCommand> commandFilter, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.InsertAllAsync(objs, commandFilter:commandFilter, token:token));
}
/// <summary>
/// Updates 1 POCO. All fields are updated except for the PrimaryKey which is used as the identity selector. E.g:
/// <para>db.Update(new Person { Id = 1, FirstName = "Jimi", LastName = "Hendrix", Age = 27 })</para>
/// </summary>
public static Task<int> UpdateAsync<T>(this IDbConnection dbConn, T obj, Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAsync(obj, token, commandFilter));
}
/// <summary>
/// Updates 1 POCO. All fields are updated except for the PrimaryKey which is used as the identity selector. E.g:
/// <para>db.Update(new Dictionary<string,object> { ["Id"] = 1, ["FirstName"] = "Jimi", ["Age"] = 27 })</para>
/// </summary>
public static Task<int> UpdateAsync<T>(this IDbConnection dbConn, Dictionary<string,object> obj, Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAsync<T>(obj, token, commandFilter));
}
/// <summary>
/// Updates 1 or more POCOs in a transaction. E.g:
/// <para>db.Update(new Person { Id = 1, FirstName = "Tupac", LastName = "Shakur", Age = 25 },</para>
/// <para>new Person { Id = 2, FirstName = "Biggie", LastName = "Smalls", Age = 24 })</para>
/// </summary>
public static Task<int> UpdateAsync<T>(this IDbConnection dbConn, CancellationToken token, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAsync(commandFilter:null, token: token, objs: objs));
}
public static Task<int> UpdateAsync<T>(this IDbConnection dbConn, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAsync(commandFilter: null, token:default, objs: objs));
}
public static Task<int> UpdateAsync<T>(this IDbConnection dbConn, Action<IDbCommand> commandFilter, CancellationToken token, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAsync(commandFilter: commandFilter, token: token, objs: objs));
}
public static Task<int> UpdateAsync<T>(this IDbConnection dbConn, Action<IDbCommand> commandFilter, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAsync(commandFilter: commandFilter, token:default, objs: objs));
}
/// <summary>
/// Updates 1 or more POCOs in a transaction. E.g:
/// <para>db.UpdateAllAsync(new[] { new Person { Id = 1, FirstName = "Jimi", LastName = "Hendrix", Age = 27 } })</para>
/// </summary>
public static Task<int> UpdateAllAsync<T>(this IDbConnection dbConn, IEnumerable<T> objs, Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.UpdateAllAsync(objs, commandFilter, token));
}
/// <summary>
/// Delete rows using an anonymous type filter. E.g:
/// <para>db.DeleteAsync<Person>(new { FirstName = "Jimi", Age = 27 })</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteAsync<T>(this IDbConnection dbConn, object anonFilter,
Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync<T>(anonFilter, token));
}
/// <summary>
/// Delete rows using an Object Dictionary filters. E.g:
/// <para>db.DeleteAsync<Person>(new Dictionary<string,object> { ["FirstName"] = "Jimi", ["Age"] = 27 })</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteAsync<T>(this IDbConnection dbConn, Dictionary<string, object> filters,
Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync<T>(filters, token));
}
/// <summary>
/// Delete 1 row using all fields in the commandFilter. E.g:
/// <para>db.DeleteAsync(new Person { Id = 1, FirstName = "Jimi", LastName = "Hendrix", Age = 27 })</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteAsync<T>(this IDbConnection dbConn, T allFieldsFilter,
Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync(allFieldsFilter, token));
}
/// <summary>
/// Delete 1 or more rows in a transaction using all fields in the commandFilter. E.g:
/// <para>db.DeleteAsync(new Person { Id = 1, FirstName = "Jimi", LastName = "Hendrix", Age = 27 })</para>
/// </summary>
public static Task<int> DeleteAsync<T>(this IDbConnection dbConn,
Action<IDbCommand> commandFilter = null, CancellationToken token = default, params T[] allFieldsFilters)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync(token, allFieldsFilters));
}
public static Task<int> DeleteAsync<T>(this IDbConnection dbConn,
Action<IDbCommand> commandFilter = null, params T[] allFieldsFilters)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync(default, allFieldsFilters));
}
/// <summary>
/// Delete 1 or more rows using only field with non-default values in the commandFilter. E.g:
/// <para>db.DeleteNonDefaultsAsync(new Person { FirstName = "Jimi", Age = 27 })</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteNonDefaultsAsync<T>(this IDbConnection dbConn, T nonDefaultsFilter, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteNonDefaultsAsync(nonDefaultsFilter, token));
}
/// <summary>
/// Delete 1 or more rows in a transaction using only field with non-default values in the commandFilter. E.g:
/// <para>db.DeleteNonDefaultsAsync(new Person { FirstName = "Jimi", Age = 27 },
/// new Person { FirstName = "Janis", Age = 27 })</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteNonDefaultsAsync<T>(this IDbConnection dbConn, CancellationToken token, params T[] nonDefaultsFilters)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteNonDefaultsAsync(token, nonDefaultsFilters));
}
public static Task<int> DeleteNonDefaultsAsync<T>(this IDbConnection dbConn, params T[] nonDefaultsFilters)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteNonDefaultsAsync(default, nonDefaultsFilters));
}
/// <summary>
/// Delete 1 row by the PrimaryKey. E.g:
/// <para>db.DeleteByIdAsync<Person>(1)</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteByIdAsync<T>(this IDbConnection dbConn, object id,
Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteByIdAsync<T>(id, commandFilter, token));
}
/// <summary>
/// Delete 1 row by the PrimaryKey where the rowVersion matches the optimistic concurrency field.
/// Will throw <exception cref="OptimisticConcurrencyException">RowModifiedException</exception> if the
/// row does not exist or has a different row version.
/// E.g: <para>db.DeleteByIdAsync<Person>(1)</para>
/// </summary>
public static Task DeleteByIdAsync<T>(this IDbConnection dbConn, object id, ulong rowVersion,
Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteByIdAsync<T>(id, rowVersion, commandFilter, token));
}
/// <summary>
/// Delete all rows identified by the PrimaryKeys. E.g:
/// <para>db.DeleteByIdsAsync<Person>(new[] { 1, 2, 3 })</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteByIdsAsync<T>(this IDbConnection dbConn, IEnumerable idValues,
Action<IDbCommand> commandFilter = null, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteByIdsAsync<T>(idValues, commandFilter, token));
}
/// <summary>
/// Delete all rows in the generic table type. E.g:
/// <para>db.DeleteAllAsync<Person>()</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteAllAsync<T>(this IDbConnection dbConn, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAllAsync<T>(token));
}
/// <summary>
/// Delete all rows in the runtime table type. E.g:
/// <para>db.DeleteAllAsync(typeof(Person))</para>
/// </summary>
/// <returns>number of rows deleted</returns>
public static Task<int> DeleteAllAsync(this IDbConnection dbConn, Type tableType, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAllAsync(tableType, token));
}
/// <summary>
/// Delete rows using sqlfilter, e.g:
/// <para>db.DeleteAsync<Person>("FirstName = @FirstName AND Age = @Age", new { FirstName = "Jimi", Age = 27 })</para>
/// </summary>
public static Task<int> DeleteAsync<T>(this IDbConnection dbConn, string sqlFilter, object anonType, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync<T>(sqlFilter, anonType, token));
}
/// <summary>
/// Delete rows using sqlfilter and Runtime Type, e.g:
/// <para>db.DeleteAsync(typeof(Person), "FirstName = @FirstName AND Age = @Age", new { FirstName = "Jimi", Age = 27 })</para>
/// </summary>
public static Task<int> DeleteAsync(this IDbConnection dbConn, Type tableType, string sqlFilter, object anonType, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.DeleteAsync(tableType, sqlFilter, anonType, token));
}
/// <summary>
/// Insert a new row or update existing row. Returns true if a new row was inserted.
/// Optional references param decides whether to save all related references as well. E.g:
/// <para>db.SaveAsync(customer, references:true)</para>
/// </summary>
/// <returns>true if a row was inserted; false if it was updated</returns>
public static async Task<bool> SaveAsync<T>(this IDbConnection dbConn, T obj, bool references = false, CancellationToken token = default)
{
if (!references)
return await dbConn.Exec(dbCmd => dbCmd.SaveAsync(obj, token)).ConfigAwait();
var trans = dbConn.OpenTransactionIfNotExists();
return await dbConn.Exec(async dbCmd =>
{
using (trans)
{
var ret = await dbCmd.SaveAsync(obj, token).ConfigAwait();
await dbCmd.SaveAllReferencesAsync(obj, token).ConfigAwait();
trans?.Commit();
return ret;
}
}).ConfigAwait();
}
/// <summary>
/// Insert new rows or update existing rows. Return number of rows added E.g:
/// <para>db.SaveAsync(new Person { Id = 10, FirstName = "Amy", LastName = "Winehouse", Age = 27 })</para>
/// </summary>
/// <returns>number of rows added</returns>
public static Task<int> SaveAsync<T>(this IDbConnection dbConn, CancellationToken token, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.SaveAsync(token, objs));
}
public static Task<int> SaveAsync<T>(this IDbConnection dbConn, params T[] objs)
{
return dbConn.Exec(dbCmd => dbCmd.SaveAsync(default, objs));
}
/// <summary>
/// Insert new rows or update existing rows. Return number of rows added E.g:
/// <para>db.SaveAllAsync(new [] { new Person { Id = 10, FirstName = "Amy", LastName = "Winehouse", Age = 27 } })</para>
/// </summary>
/// <returns>number of rows added</returns>
public static Task<int> SaveAllAsync<T>(this IDbConnection dbConn, IEnumerable<T> objs, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.SaveAllAsync(objs, token));
}
/// <summary>
/// Populates all related references on the instance with its primary key and saves them. Uses '(T)Id' naming convention. E.g:
/// <para>db.SaveAllReferences(customer)</para>
/// </summary>
public static Task SaveAllReferencesAsync<T>(this IDbConnection dbConn, T instance, CancellationToken token=default)
{
return dbConn.Exec(dbCmd => dbCmd.SaveAllReferencesAsync(instance, token));
}
/// <summary>
/// Populates the related references with the instance primary key and saves them. Uses '(T)Id' naming convention. E.g:
/// <para>db.SaveReference(customer, customer.Orders)</para>
/// </summary>
public static Task SaveReferencesAsync<T, TRef>(this IDbConnection dbConn, CancellationToken token, T instance, params TRef[] refs)
{
return dbConn.Exec(dbCmd => dbCmd.SaveReferencesAsync(token, instance, refs));
}
public static Task SaveReferencesAsync<T, TRef>(this IDbConnection dbConn, T instance, params TRef[] refs)
{
return dbConn.Exec(dbCmd => dbCmd.SaveReferencesAsync(default, instance, refs));
}
/// <summary>
/// Populates the related references with the instance primary key and saves them. Uses '(T)Id' naming convention. E.g:
/// <para>db.SaveReference(customer, customer.Orders)</para>
/// </summary>
public static Task SaveReferencesAsync<T, TRef>(this IDbConnection dbConn, T instance, List<TRef> refs, CancellationToken token=default)
{
return dbConn.Exec(dbCmd => dbCmd.SaveReferencesAsync(token, instance, refs.ToArray()));
}
/// <summary>
/// Populates the related references with the instance primary key and saves them. Uses '(T)Id' naming convention. E.g:
/// <para>db.SaveReferences(customer, customer.Orders)</para>
/// </summary>
public static Task SaveReferencesAsync<T, TRef>(this IDbConnection dbConn, T instance, IEnumerable<TRef> refs, CancellationToken token)
{
return dbConn.Exec(dbCmd => dbCmd.SaveReferencesAsync(token, instance, refs.ToArray()));
}
public static Task<object> GetRowVersionAsync<T>(this IDbConnection dbConn, object id, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.GetRowVersionAsync(typeof(T).GetModelDefinition(), id, token));
}
public static Task<object> GetRowVersionAsync(this IDbConnection dbConn, Type modelType, object id, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.GetRowVersionAsync(modelType.GetModelDefinition(), id, token));
}
// Procedures
public static Task ExecuteProcedureAsync<T>(this IDbConnection dbConn, T obj, CancellationToken token = default)
{
return dbConn.Exec(dbCmd => dbCmd.ExecuteProcedureAsync(obj, token));
}
}
}
#endif