@@ -9,21 +9,61 @@ namespace ServiceStack.OrmLite
9
9
public class TemplateDbFilters : TemplateFilter
10
10
{
11
11
public IDbConnectionFactory DbFactory { get ; set ; }
12
- T exec < T > ( Func < IDbConnection , T > fn )
12
+
13
+ T exec < T > ( Func < IDbConnection , T > fn , TemplateScopeContext scope , object options )
13
14
{
14
- using ( var db = DbFactory . Open ( ) )
15
+ try
16
+ {
17
+ using ( var db = DbFactory . Open ( ) )
18
+ {
19
+ return fn ( db ) ;
20
+ }
21
+ }
22
+ catch ( Exception ex )
15
23
{
16
- return fn ( db ) ;
24
+ throw new StopFilterExecutionException ( scope , options , ex ) ;
17
25
}
18
26
}
19
27
20
- public object dbSelect ( string sql ) => exec ( db => db . Select < Dictionary < string , object > > ( sql ) ) ;
21
- public object dbSelect ( string sql , Dictionary < string , object > args ) => exec ( db => db . Select < Dictionary < string , object > > ( sql , args ) ) ;
22
- public object dbSingle ( string sql ) => exec ( db => db . Single < Dictionary < string , object > > ( sql ) ) ;
23
- public object dbSingle ( string sql , Dictionary < string , object > args ) => exec ( db => db . Single < Dictionary < string , object > > ( sql , args ) ) ;
24
- public object dbScalar ( string sql ) => exec ( db => db . Scalar < object > ( sql ) ) ;
25
- public object dbScalar ( string sql , Dictionary < string , object > args ) => exec ( db => db . Scalar < object > ( sql , args ) ) ;
26
- public int dbExec ( string sql , Dictionary < string , object > args ) => exec ( db => db . ExecuteSql ( sql , args ) ) ;
28
+ public object dbSelect ( TemplateScopeContext scope , string sql ) =>
29
+ exec ( db => db . Select < Dictionary < string , object > > ( sql ) , scope , null ) ;
30
+
31
+ public object dbSelect ( TemplateScopeContext scope , string sql , Dictionary < string , object > args ) =>
32
+ exec ( db => db . Select < Dictionary < string , object > > ( sql , args ) , scope , null ) ;
33
+
34
+ public object dbSelect ( TemplateScopeContext scope , string sql , Dictionary < string , object > args , object options ) =>
35
+ exec ( db => db . Select < Dictionary < string , object > > ( sql , args ) , scope , options ) ;
36
+
37
+
38
+ public object dbSingle ( TemplateScopeContext scope , string sql ) =>
39
+ exec ( db => db . Single < Dictionary < string , object > > ( sql ) , scope , null ) ;
40
+
41
+ public object dbSingle ( TemplateScopeContext scope , string sql , Dictionary < string , object > args ) =>
42
+ exec ( db => db . Single < Dictionary < string , object > > ( sql , args ) , scope , null ) ;
43
+
44
+ public object dbSingle ( TemplateScopeContext scope , string sql , Dictionary < string , object > args , object options ) =>
45
+ exec ( db => db . Single < Dictionary < string , object > > ( sql , args ) , scope , options ) ;
46
+
47
+
48
+ public object dbScalar ( TemplateScopeContext scope , string sql ) =>
49
+ exec ( db => db . Scalar < object > ( sql ) , scope , null ) ;
50
+
51
+ public object dbScalar ( TemplateScopeContext scope , string sql , Dictionary < string , object > args ) =>
52
+ exec ( db => db . Scalar < object > ( sql , args ) , scope , null ) ;
53
+
54
+ public object dbScalar ( TemplateScopeContext scope , string sql , Dictionary < string , object > args , object options ) =>
55
+ exec ( db => db . Scalar < object > ( sql , args ) , scope , options ) ;
56
+
57
+
58
+ public int dbExec ( TemplateScopeContext scope , string sql ) =>
59
+ exec ( db => db . ExecuteSql ( sql ) , scope , null ) ;
60
+
61
+ public int dbExec ( TemplateScopeContext scope , string sql , Dictionary < string , object > args ) =>
62
+ exec ( db => db . ExecuteSql ( sql , args ) , scope , null ) ;
63
+
64
+ public int dbExec ( TemplateScopeContext scope , string sql , Dictionary < string , object > args , object options ) =>
65
+ exec ( db => db . ExecuteSql ( sql , args ) , scope , options ) ;
66
+
27
67
28
68
public string sqlQuote ( string name ) => OrmLiteConfig . DialectProvider . GetQuotedName ( name ) ;
29
69
public string sqlConcat ( IEnumerable < object > values ) => OrmLiteConfig . DialectProvider . SqlConcat ( values ) ;
0 commit comments