ObjectParameter.Value Propiedad

Definición

Obtiene o establece el valor de parámetro.

public:
 property System::Object ^ Value { System::Object ^ get(); void set(System::Object ^ value); };
public object Value { get; set; }
member this.Value : obj with get, set
Public Property Value As Object

Valor de propiedad

Valor del parámetro.

Ejemplos

En este ejemplo se agregan nuevos parámetros a la colección. Se recorre en iteración la ObjectParameterCollection y se muestra el nombre, el tipo y el valor de cada parámetro de la colección.

using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString =
        @"SELECT VALUE contact FROM AdventureWorksEntities.Contacts
        AS contact WHERE contact.LastName = @ln
        AND contact.FirstName = @fn";

    ObjectQuery<Contact> contactQuery =
        new ObjectQuery<Contact>(queryString, context);

    // Add parameters to the collection.
    contactQuery.Parameters.Add(new ObjectParameter("ln", "Adams"));
    contactQuery.Parameters.Add(new ObjectParameter("fn", "Frances"));

    ObjectParameterCollection objectParameterCollection =
        contactQuery.Parameters;

    // Iterate through the ObjectParameterCollection.
    foreach (ObjectParameter result in objectParameterCollection)
    {
        Console.WriteLine("{0} {1} {2}", result.Name,
            result.Value,
            result.ParameterType);
    }
}

Comentarios

Una vez compilada la consulta, el valor no se puede cambiar. Para obtener más información, vea Métodos del Generador de consultas.

Si el nuevo valor es no es compatible con el tipo declarado en el constructor, se puede producir una excepción en tiempo de ejecución. El proveedor debe determinar si el valor es compatible con el tipo declarado. Por ejemplo, si el tipo inicial es Int32 y el nuevo valor es Guid, podría recibir una excepción.

Se aplica a

Consulte también