1
1
using Plugin ;
2
2
using RubyCodegen ;
3
- using System ;
4
3
using System . Collections . Generic ;
5
4
using System . Linq ;
6
5
@@ -59,38 +58,36 @@ public MethodDeclaration ManyDeclare(string funcName, string queryTextConstant,
59
58
string returnInterface , IList < Parameter > parameters , IList < Column > columns , bool poolingEnabled = true ,
60
59
RowDataType rowDataType = RowDataType . Hash )
61
60
{
62
- var listAppend = new ListAppend ( Variable . Entities . AsVar ( ) ,
63
- new NewObject ( returnInterface , GetColumnsInitExpressions ( columns , rowDataType ) ) ) ;
64
- IEnumerable < IComposable > withResourceBody = new List < IComposable > ( ) ;
65
61
var queryParams = GetQueryParams ( argInterface , parameters ) ;
66
- withResourceBody = withResourceBody . AppendIfNotNull ( queryParams ) ;
67
- withResourceBody = withResourceBody
68
- . Concat (
69
- [
70
- dbDriver . PrepareStmt ( funcName , queryTextConstant ) ,
71
- ExecuteAndAssign ( funcName , queryParams ) ,
72
- new SimpleStatement ( Variable . Entities . AsVar ( ) , new SimpleExpression ( "[]" ) ) ,
73
- new ForeachLoop (
74
- Variable . Result . AsVar ( ) ,
75
- Variable . Row . AsVar ( ) ,
76
- new List < IComposable > { listAppend }
77
- ) ,
78
- new SimpleExpression ( $ "return { Variable . Entities . AsVar ( ) } ")
79
- ]
80
- ) ;
62
+ var withResourceBody = new List < IComposable > ( )
63
+ . AppendIfNotNull ( queryParams )
64
+ . Append ( dbDriver . PrepareStmt ( funcName , queryTextConstant ) )
65
+ . Append ( ExecuteAndAssign ( funcName , queryParams ) )
66
+ . Append ( new SimpleStatement ( Variable . Entities . AsVar ( ) , new SimpleExpression ( "[]" ) ) )
67
+ . Append ( AssignResultInForeach ( ) )
68
+ . Append ( new SimpleExpression ( $ "return { Variable . Entities . AsVar ( ) } ") ) ;
81
69
82
70
var methodArgs = GetMethodArgs ( argInterface , parameters ) ;
83
71
var methodBody = OptionallyAddPoolUsage ( poolingEnabled , withResourceBody ) ;
84
72
return new MethodDeclaration ( funcName , argInterface , methodArgs , null , methodBody ) ;
73
+
74
+ ForeachLoop AssignResultInForeach ( )
75
+ {
76
+ var listAppend = new ListAppend ( Variable . Entities . AsVar ( ) ,
77
+ new NewObject ( returnInterface , GetColumnsInitExpressions ( columns , rowDataType ) ) ) ;
78
+ return new ForeachLoop (
79
+ Variable . Result . AsVar ( ) ,
80
+ Variable . Row . AsVar ( ) ,
81
+ new List < IComposable > { listAppend } ) ;
82
+ }
85
83
}
86
84
87
85
public MethodDeclaration ExecDeclare ( string funcName , string queryTextConstant , string argInterface ,
88
86
IList < Parameter > parameters , bool poolingEnabled = true )
89
87
{
90
- IEnumerable < IComposable > withResourceBody = new List < IComposable > ( ) ;
91
88
var queryParams = GetQueryParams ( argInterface , parameters ) ;
92
- withResourceBody = withResourceBody . AppendIfNotNull ( queryParams ) ;
93
- withResourceBody = withResourceBody
89
+ var withResourceBody = new List < IComposable > ( )
90
+ . AppendIfNotNull ( queryParams )
94
91
. Append ( dbDriver . PrepareStmt ( funcName , queryTextConstant ) )
95
92
. Append ( dbDriver . ExecuteStmt ( funcName , queryParams ) )
96
93
. ToList ( ) ;
@@ -103,17 +100,12 @@ public MethodDeclaration ExecDeclare(string funcName, string queryTextConstant,
103
100
public MethodDeclaration ExecLastIdDeclare ( string funcName , string queryTextConstant , string argInterface ,
104
101
IList < Parameter > parameters )
105
102
{
106
- IEnumerable < IComposable > withResourceBody = new List < IComposable > ( ) ;
107
103
var queryParams = GetQueryParams ( argInterface , parameters ) ;
108
- withResourceBody = withResourceBody . AppendIfNotNull ( queryParams ) ;
109
- withResourceBody = withResourceBody
110
- . Concat (
111
- [
112
- dbDriver . PrepareStmt ( funcName , queryTextConstant ) ,
113
- dbDriver . ExecuteStmt ( funcName , queryParams ) ,
114
- new SimpleExpression ( $ "return { Variable . Client . AsVar ( ) } .last_id")
115
- ]
116
- ) ;
104
+ var withResourceBody = new List < IComposable > ( )
105
+ . AppendIfNotNull ( queryParams )
106
+ . Append ( dbDriver . PrepareStmt ( funcName , queryTextConstant ) )
107
+ . Append ( dbDriver . ExecuteStmt ( funcName , queryParams ) )
108
+ . Append ( new SimpleExpression ( $ "return { Variable . Client . AsVar ( ) } .last_id") ) ;
117
109
118
110
return new MethodDeclaration (
119
111
funcName ,
0 commit comments