Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
ObjectParameter Class

Represents a query parameter that is passed to an object query.

System..::.Object
  System.Data.Objects..::.ObjectParameter

Namespace:  System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)
Visual Basic
Public NotInheritable Class ObjectParameter
C#
public sealed class ObjectParameter
Visual C++
public ref class ObjectParameter sealed
F#
[<Sealed>]
type ObjectParameter =  class end

The ObjectParameter type exposes the following members.

  NameDescription
Public methodObjectParameter(String, Object)Initializes a new instance of the ObjectParameter class with the specified name and value.
Public methodObjectParameter(String, Type)Initializes a new instance of the ObjectParameter class with the specified name and type.
Top
  NameDescription
Public propertyNameGets the parameter name, which can only be set through a constructor.
Public propertyParameterTypeGets the parameter type.
Public propertyValueGets or sets the parameter value.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Represents a query parameter that is passed to an ObjectQuery<(Of <(T>)>) or a query builder method. For more information, see Query Builder Methods (Entity Framework).

Object parameters consist of a name, a type, and a value.

This class cannot be inherited. For more information, see ObjectParameterCollection.

The example in this topic is based on the Adventure Works Sales Model. The example adds new parameters to the collection. It iterates through the ObjectParameterCollection and displays the name, type, and value of each parameter in the collection.

Visual Basic
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
C#
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);
    }
}

.NET Framework

Supported in: 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Biblioteca de clases de .NET Framework
ObjectParameter (Clase)

Representa un parámetro de consulta que se pasa a una consulta de objeto.

System..::.Object
  System.Data.Objects..::.ObjectParameter

Espacio de nombres:  System.Data.Objects
Ensamblado:  System.Data.Entity (en System.Data.Entity.dll)
Visual Basic
Public NotInheritable Class ObjectParameter
C#
public sealed class ObjectParameter
Visual C++
public ref class ObjectParameter sealed
F#
[<Sealed>]
type ObjectParameter =  class end

El tipo ObjectParameter expone los siguientes miembros.

  NombreDescripción
Método públicoObjectParameter(String, Object)Inicializa una nueva instancia de la clase ObjectParameter con el nombre y el valor especificados.
Método públicoObjectParameter(String, Type)Inicializa una nueva instancia de la clase ObjectParameter con el nombre y el tipo especificados.
Arriba
  NombreDescripción
Propiedad públicaNameObtiene el nombre de parámetro, que se puede establecer únicamente a través de un constructor.
Propiedad públicaParameterTypeObtiene el tipo de parámetro.
Propiedad públicaValueObtiene o establece el valor del parámetro.
Arriba
  NombreDescripción
Método públicoEquals(Object)Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object).
Método protegidoFinalizePermite que un objeto intente liberar recursos y realizar otras operaciones de limpieza antes de ser reclamado por la recolección de elementos no utilizados. (Se hereda de Object).
Método públicoGetHashCodeActúa como función hash para un tipo concreto. (Se hereda de Object).
Método públicoGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método protegidoMemberwiseCloneCrea una copia superficial del objeto Object actual. (Se hereda de Object).
Método públicoToStringDevuelve una cadena que representa el objeto actual. (Se hereda de Object).
Arriba

Representa un parámetro de consulta que se pasa a una ObjectQuery<(Of <(T>)>) o un método del generador de consultas. Para obtener más información, vea Query Builder Methods (Entity Framework).

Los parámetros de objeto se componen de un nombre, un tipo y un valor.

Esta clase no puede heredarse. Para obtener más información, vea ObjectParameterCollection.

El ejemplo de este tema se basa en el Adventure Works Sales Model. En el 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.

Visual Basic
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
C#
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);
    }
}

.NET Framework

Compatible con: 4, 3.5 SP1

.NET Framework Client Profile

Compatible con: 4

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker