public void DbCommandProcedure(ProcedureTO to) { using (var connection = CreateDbConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = "FXUSER." + to.Name; command.CommandType = CommandType.StoredProcedure; connection.Open(); foreach (var item in to.Parameters) { switch (item.Direction) { case ProcedureParameterDirection.In: command.AddInputParameter(item.Name, item.Value, item.Type); break; case ProcedureParameterDirection.Out: command.AddOutputParameter(item.Name, item.Type); break; } } command.ExecuteNonQuery(); } } }
protected ResultTO DbCommandProcedure(ProcedureTO to) { var resultTO = new ResultTO(); using (var connection = CreateDbConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = "FXUSER." + to.Name; command.CommandType = CommandType.StoredProcedure; connection.Open(); foreach (var item in to.Parameters) { switch (item.Direction) { case ProcedureParameterDirection.In: command.AddInputParameter(item.Name, item.Value, item.Type); break; case ProcedureParameterDirection.Out: command.AddOutputParameter(item.Name, item.Type); break; } } command.ExecuteNonQuery(); resultTO.Message = command.Parameters[to.Parameters .Where(i => i.Direction == ProcedureParameterDirection.Out) .FirstOrDefault().Name].Value.ToString(); resultTO.Result = (resultTO.Message == "OK") ? Result.Pass : Result.Fail; } } return(resultTO); }
public ResultTO Execute(ProcedureTO procedure) { return(base.DbCommandProcedure(procedure)); }