ObjectQuery.Parameters ObjectQuery.Parameters ObjectQuery.Parameters ObjectQuery.Parameters Property

Definición

Obtiene la colección de parámetros para esta consulta de objeto.Gets the parameter collection for this object query.

public:
 property System::Data::Objects::ObjectParameterCollection ^ Parameters { System::Data::Objects::ObjectParameterCollection ^ get(); };
public System.Data.Objects.ObjectParameterCollection Parameters { get; }
member this.Parameters : System.Data.Objects.ObjectParameterCollection
Public ReadOnly Property Parameters As ObjectParameterCollection

Valor de propiedad

Ejemplos

Este ejemplo se basa en el modelo AdventureWorks Sales.This example is based on the AdventureWorks Sales Model. En el ejemplo, se agregan nuevos parámetros a la colección y, a continuación, se obtiene la colección de parámetros para esta ObjectQuery<T>.The example adds new parameters to the collection and then gets the parameter collection for this ObjectQuery<T>. A continuació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.Then it iterates through the ObjectParameterCollection and displays the name, type, and value of each parameter in the collection.

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);
    }
}
Using context As New AdventureWorksEntities()
    Dim queryString As String = "SELECT VALUE contact FROM AdventureWorksEntities.Contacts" & _
            " AS contact WHERE contact.LastName = @ln AND contact.FirstName = @fn"

    Dim contactQuery As New ObjectQuery(Of Contact)(queryString, context)

    ' Add parameters to the collection. 
    contactQuery.Parameters.Add(New ObjectParameter("ln", "Adams"))
    contactQuery.Parameters.Add(New ObjectParameter("fn", "Frances"))

    Dim objectParameterCollection As ObjectParameterCollection = contactQuery.Parameters

    ' Iterate through the ObjectParameterCollection. 
    For Each result As ObjectParameter In objectParameterCollection
        Console.WriteLine("{0} {1} {2}", result.Name, result.Value, result.ParameterType)
    Next
End Using

Comentarios

Use la ObjectParameterCollection devuelta para especificar los parámetros que se pasan a la consulta.Use the returned ObjectParameterCollection to specify parameters that are passed to the query. Para obtener más información, vea métodos generador de consultas.For more information, see Query Builder Methods.

Se aplica a

Consulte también: