I have been using the CTF in EA 7 to create code however I have hit a wall with looping and parameters. I would like to create a code template that utilises the parameters defined in an operation.
For example, I have an operation defined as:
public DataSet GetName(string Name, string Address)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand("search");
db.AddInParameter(cmd, "Name", DbType.String, Name);
db.AddInParameter(cmd, "Address", DbType.String, Address);
return db.ExecuteDataSet(cmd);
}
The built in templates produce the following:
public DataSet GetName(string Name, string Address)
{
return null;
}
I can easily add in:
public DataSet GetName(string Name, string Address)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand("search");
return db.ExecuteDataSet(cmd);
}
I would like to create a CTF operation template to process the parameters so that for each parameter it adds:
db.AddInParameter(cmd, %ParamName%, %DBType%, %ParamName%);
The template for the method would be:
public DataSet OperationName(params)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand(%SP_NAME%);
foreach(param in params)
{
db.AddInParameter(cmd, %ParamName%, %DBType%, %ParamName%);
}
return db.ExecuteDataSet(cmd);
}
In the EA guide an example uses %list="Parameter" @separator=", "% to fetch all of the parameters but there appears to be no looping mechanism to loop through each parameter so that I can:
1) Work out the type
2) Grab the name
The second thing that I would like to work out is if there is a way to pass in variables for a particular operation. For example the operation could have a stored procedure naame associated to it.
Any help with the above would be greatly appreciated.
Thanks,
Gavin