Пример #1
0
        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));
                    }
                }
            }
        }
Пример #2
0
 public Type DataTypeToClrType(string dataType)
 {
     return(SqlTypeResolver.GetClrType(dataType));
 }
Пример #3
0
 private static Parameter SchemaRowToProcedureParameter(DataRow row)
 {
     return(new Parameter(row["parameter_name"].ToString(), SqlTypeResolver.GetClrType(row["data_type"].ToString()),
                          DirectionFromString(row["parameter_mode"].ToString())));
 }