public IEnumerable <Parameter> GetParameters(Procedure storedProcedure) { // GetSchema does not return the return value of e.g. a stored proc correctly, // i.e. there isn't sufficient information to correctly set up a stored proc. using (var connection = (SqlConnection)ConnectionProvider.CreateConnection()) { using (var command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = storedProcedure.QualifiedName; connection.Open(); SqlCommandBuilder.DeriveParameters(command); //Tim Cartwright: I added size and dbtype so inout/out params would function properly. foreach (SqlParameter p in command.Parameters) { yield return(new Parameter(p.ParameterName, SqlTypeResolver.GetClrType(p.DbType.ToString()), p.Direction, p.DbType, p.Size)); } } } }
public Type DataTypeToClrType(string dataType) { return(SqlTypeResolver.GetClrType(dataType)); }
private static Parameter SchemaRowToProcedureParameter(DataRow row) { return(new Parameter(row["parameter_name"].ToString(), SqlTypeResolver.GetClrType(row["data_type"].ToString()), DirectionFromString(row["parameter_mode"].ToString()))); }