// generate parameter (name based on parameter ordinal) internal IngresParameter CreateParameter(object value, TypeUsage type) { PrimitiveTypeKind primitiveType = MetadataHelpers.GetPrimitiveTypeKind(type); IngresType dbType = MetadataHelpers.GetIngresType(primitiveType); return(CreateParameter(value, dbType)); }
// Creates a new parameter for a value in this expression translator internal IngresParameter CreateParameter(object value, IngresType dbType) { string parameterName = string.Concat("@p", parameterNameCount.ToString(CultureInfo.InvariantCulture)); parameterNameCount++; IngresParameter parameter = new IngresParameter(parameterName, value); parameter.IngresType = dbType; _parameters.Add(parameter); return(parameter); }
} // ApplyParameterInfo /// <summary> /// Populate the IngresCommand.Parameters collection with data type /// metadata about the parameters of the specified database procedure. /// </summary> /// <param name="command"></param> public static void DeriveParameters(IngresCommand command) { if (command == null) { throw new ArgumentNullException( "DeriveParameters parameter 'command' must not be null."); } IngresConnection conn = command.Connection; if (conn == null || conn.State != ConnectionState.Open) { throw new InvalidOperationException( "The IngresCommand.Connection must be specified and open."); } if (command.CommandText == null || command.CommandText.Length == 0) { throw new InvalidOperationException( "The IngresCommand.CommandText must be specify a procedure name."); } if (command.CommandType != CommandType.StoredProcedure) { throw new InvalidOperationException( "Only CommandType.StoredProcedure is supported."); } ArrayList tokens = Ingres.ProviderInternals.MetaData.ScanSqlStatement( command.CommandText); String[] restriction = new String[3]; if (tokens.Count == 1) // procname { restriction[2] = UnquoteIdent((String)tokens[0], conn, "\"", "\""); } else if (tokens.Count == 3 && // schemaname.procname (String)tokens[1] == ".") { restriction[1] = UnquoteIdent((String)tokens[0], conn, "\"", "\""); restriction[2] = UnquoteIdent((String)tokens[2], conn, "\"", "\""); } else if (tokens.Count == 5 && // catalogname.schemaname.procname (String)tokens[1] == "." && (String)tokens[3] == ".") { restriction[0] = UnquoteIdent((String)tokens[0], conn, "\"", "\""); restriction[1] = UnquoteIdent((String)tokens[2], conn, "\"", "\""); restriction[2] = UnquoteIdent((String)tokens[4], conn, "\"", "\""); } else { throw new InvalidOperationException( "Invalid procedure name."); } DataTable datatable = conn.GetSchema("ProcedureParameters", restriction); command.Parameters.Clear(); foreach (DataRow row in datatable.Rows) { string name = (String)row["COLUMN_NAME"]; IngresType ingresType = (IngresType)row["INGRESTYPE"]; IngresParameter parm = new IngresParameter(name, ingresType); command.Parameters.Add(parm); } // end foreach (DataRow row in datatable) }
/// <summary> /// Create a parameter object and add it to the parameter collection. /// </summary> /// <param name="parameterName"></param> /// <param name="type"></param> /// <returns></returns> public IngresParameter Add(string parameterName, IngresType type) { return Add(new IngresParameter(parameterName, type)); }
/// <summary> /// Create a parameter object and add it to the parameter collection. /// </summary> /// <param name="parameterName"></param> /// <param name="type"></param> /// <param name="sourceColumn"></param> /// <returns></returns> public IngresParameter Add( string parameterName, IngresType type, string sourceColumn) { return Add(new IngresParameter(parameterName, type, sourceColumn)); }
/// <summary> /// Create a parameter object with a parameter name, /// provider data type, parameter length, direction, nullability, /// numeric precision, numeric scale, source column name, /// source data row version, and data value. /// </summary> /// <param name="parameterName"></param> /// <param name="provType"></param> /// <param name="size"></param> /// <param name="direction"></param> /// <param name="isNullable"></param> /// <param name="precision"></param> /// <param name="scale"></param> /// <param name="sourceColumn"></param> /// <param name="sourceVersion"></param> /// <param name="value"></param> public IngresParameter( string parameterName, IngresType provType, // IngresType int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value) { this.ParameterName = parameterName; this.ProviderType = (ProviderType)provType; // also infers the DbType this.Size = size; this.Direction = direction; this.IsNullable = isNullable; this.Precision = precision; this.Scale = scale; this.SourceColumn = sourceColumn; this.SourceVersion = sourceVersion; this.Value = value; }
/// <summary> /// Create a parameter object with a parameter name, /// provider data type, parameter length, and source column name. /// </summary> /// <param name="parameterName"></param> /// <param name="provType"></param> /// <param name="size"></param> /// <param name="sourceColumn"></param> public IngresParameter( string parameterName, IngresType provType, // IngresType int size, string sourceColumn) { this.ParameterName = parameterName; this.ProviderType = (ProviderType)provType; // also infers the DbType this.Size = size; this.SourceColumn = sourceColumn; }
/// <summary> /// Create a parameter object with a parameter name, /// provider data type, and parameter length. /// </summary> /// <param name="parameterName"></param> /// <param name="provType"></param> /// <param name="size"></param> public IngresParameter( string parameterName, IngresType provType, // IngresType int size) { this.ParameterName = parameterName; this.ProviderType = (ProviderType)provType; this.Size = size; }
/// <summary> /// Create a parameter object with a parameter name, /// provider data type, and source column name. /// </summary> /// <param name="parameterName"></param> /// <param name="provType"></param> /// <param name="sourceColumn"></param> public IngresParameter( string parameterName, IngresType provType, // IngresType string sourceColumn) { this.ParameterName = parameterName; this.ProviderType = (ProviderType)provType; this.SourceColumn = sourceColumn; }
/// <summary> /// Create a parameter object with a parameter name and a provider data type. /// </summary> /// <param name="parameterName"></param> /// <param name="provType"></param> public IngresParameter( string parameterName, IngresType provType) // IngresType { this.ParameterName = parameterName; this.ProviderType = (ProviderType)provType; }