The easy and simple way is using Dapper .
var cliente = connection.Query<Cliente>("PROC_Select_Cliente", new {ID = 1},
commandType: CommandType.StoredProcedure).First();
var parametros = new DynamicParameters();
parametros.Add("@ID", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
parametros.Add("@Nome", "Fulano");
parametros.Add("@Telefone", "(11) 2345-6789");
connection.Execute("PROC_Insert_Cliente", parametros, commandType: CommandType.StoredProcedure);
int id = parametros.Get<int>("@ID");
Remembering that connection
is any object that implements IDbConnection
. It can be SqlConnection
, for example.
Now, passing an object to a function that executes a Stored Procedure is a step a little further. I do not know if it's worth detailing in this answer.