Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 801f4b6

Browse files
committed
Add sync overloads for all DbScriptsAsync script methods
1 parent 812cc3c commit 801f4b6

File tree

2 files changed

+90
-3
lines changed

2 files changed

+90
-3
lines changed

src/ServiceStack.OrmLite/DbScripts.cs

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class DbScripts : ScriptMethods
1818
private IDbConnectionFactory dbFactory;
1919
public IDbConnectionFactory DbFactory
2020
{
21-
get => dbFactory ?? (dbFactory = Context.Container.Resolve<IDbConnectionFactory>());
21+
get => dbFactory ??= Context.Container.Resolve<IDbConnectionFactory>();
2222
set => dbFactory = value;
2323
}
2424

@@ -197,4 +197,91 @@ public ColumnSchema[] dbColumns(ScriptScopeContext scope, string tableName, obje
197197

198198
private string padCondition(string text) => string.IsNullOrEmpty(text) ? "" : " " + text;
199199
}
200+
201+
public partial class DbScriptsAsync
202+
{
203+
private static DbScripts Sync = new DbScripts();
204+
205+
public object dbSelectSync(ScriptScopeContext scope, string sql) => Sync.dbSelect(scope, sql);
206+
207+
public object dbSelectSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args) =>
208+
Sync.dbSelect(scope, sql, args);
209+
210+
public object dbSelectSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args, object options) =>
211+
Sync.dbSelect(scope, sql, args, options);
212+
213+
214+
public object dbSingleSync(ScriptScopeContext scope, string sql) =>
215+
Sync.dbSingle(scope, sql);
216+
217+
public object dbSingleSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args) =>
218+
Sync.dbSingle(scope, sql, args);
219+
220+
public object dbSingleSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args, object options) =>
221+
Sync.dbSingle(scope, sql, args, options);
222+
223+
224+
public object dbScalarSync(ScriptScopeContext scope, string sql) =>
225+
Sync.dbScalar(scope, sql);
226+
227+
public object dbScalarSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args) =>
228+
Sync.dbScalar(scope, sql, args);
229+
230+
public object dbScalarSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args, object options) =>
231+
Sync.dbScalar(scope, sql, args, options);
232+
233+
234+
public long dbCountSync(ScriptScopeContext scope, string sql) =>
235+
Sync.dbCount(scope, sql);
236+
237+
public long dbCountSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args) =>
238+
Sync.dbCount(scope, sql, args);
239+
240+
public long dbCountSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args, object options) =>
241+
Sync.dbCount(scope, sql, args, options);
242+
243+
244+
public bool dbExistsSync(ScriptScopeContext scope, string sql) =>
245+
Sync.dbExists(scope, sql);
246+
247+
public bool dbExistsSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args) =>
248+
Sync.dbExists(scope, sql, args);
249+
250+
public bool dbExistsSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args, object options) =>
251+
Sync.dbExists(scope, sql, args, options);
252+
253+
254+
public int dbExecSync(ScriptScopeContext scope, string sql) =>
255+
Sync.dbExec(scope, sql);
256+
257+
public int dbExecSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args) =>
258+
Sync.dbExec(scope, sql, args);
259+
260+
public int dbExecSync(ScriptScopeContext scope, string sql, Dictionary<string, object> args, object options) =>
261+
Sync.dbExec(scope, sql, args, options);
262+
263+
public List<string> dbTableNamesSync(ScriptScopeContext scope) => dbTableNamesSync(scope, null, null);
264+
public List<string> dbTableNamesSync(ScriptScopeContext scope, Dictionary<string, object> args) => dbTableNamesSync(scope, args, null);
265+
public List<string> dbTableNamesSync(ScriptScopeContext scope, Dictionary<string, object> args, object options) =>
266+
Sync.dbTableNames(scope, args, options);
267+
268+
public List<KeyValuePair<string, long>> dbTableNamesWithRowCountsSync(ScriptScopeContext scope) =>
269+
dbTableNamesWithRowCountsSync(scope, null, null);
270+
public List<KeyValuePair<string, long>> dbTableNamesWithRowCountsSync(ScriptScopeContext scope, Dictionary<string, object> args) =>
271+
dbTableNamesWithRowCountsSync(scope, args, null);
272+
public List<KeyValuePair<string, long>> dbTableNamesWithRowCountsSync(ScriptScopeContext scope, Dictionary<string, object> args, object options) =>
273+
Sync.dbTableNamesWithRowCounts(scope, args, options);
274+
275+
public string[] dbColumnNamesSync(ScriptScopeContext scope, string tableName) => dbColumnNamesSync(scope, tableName, null);
276+
public string[] dbColumnNamesSync(ScriptScopeContext scope, string tableName, object options) =>
277+
dbColumnsSync(scope, tableName, options).Select(x => x.ColumnName).ToArray();
278+
279+
public ColumnSchema[] dbColumnsSync(ScriptScopeContext scope, string tableName) => dbColumnsSync(scope, tableName, null);
280+
public ColumnSchema[] dbColumnsSync(ScriptScopeContext scope, string tableName, object options) =>
281+
Sync.dbColumns(scope, tableName, options);
282+
283+
public ColumnSchema[] dbDescSync(ScriptScopeContext scope, string sql) => dbDescSync(scope, sql, null);
284+
public ColumnSchema[] dbDescSync(ScriptScopeContext scope, string sql, object options) =>
285+
Sync.dbDesc(scope, sql, options);
286+
}
200287
}

src/ServiceStack.OrmLite/DbScriptsAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ namespace ServiceStack.OrmLite
1212
[Obsolete("Use DbScriptsAsync")]
1313
public class TemplateDbFiltersAsync : DbScriptsAsync {}
1414

15-
public class DbScriptsAsync : ScriptMethods
15+
public partial class DbScriptsAsync : ScriptMethods
1616
{
1717
private const string DbInfo = "__dbinfo"; // Keywords.DbInfo
1818
private const string DbConnection = "__dbconnection"; // useDbConnection global
1919

2020
private IDbConnectionFactory dbFactory;
2121
public IDbConnectionFactory DbFactory
2222
{
23-
get => dbFactory ?? (dbFactory = Context.Container.Resolve<IDbConnectionFactory>());
23+
get => dbFactory ??= Context.Container.Resolve<IDbConnectionFactory>();
2424
set => dbFactory = value;
2525
}
2626

0 commit comments

Comments
 (0)