ObjectParameterCollection.CopyTo(ObjectParameter[], Int32) Méthode

Définition

Autorise la copie des paramètres de la collection dans un tableau fourni, en commençant par l’objet à l’index spécifié.

public:
 virtual void CopyTo(cli::array <System::Data::Objects::ObjectParameter ^> ^ array, int index);
public void CopyTo (System.Data.Objects.ObjectParameter[] array, int index);
abstract member CopyTo : System.Data.Objects.ObjectParameter[] * int -> unit
override this.CopyTo : System.Data.Objects.ObjectParameter[] * int -> unit
Public Sub CopyTo (array As ObjectParameter(), index As Integer)

Paramètres

array
ObjectParameter[]

Tableau dans lequel copier les paramètres.

index
Int32

Index à partir duquel commencer la copie des paramètres dans le tableau.

Implémente

Exemples

Cet exemple montre comment copier les paramètres dans le tableau spécifié.

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;
    ObjectParameter[] objectParameterArray =
        new ObjectParameter[objectParameterCollection.Count];

    objectParameterCollection.CopyTo(objectParameterArray, 0);

    // Iterate through the ObjectParameter array.
    for (int i = 0; i < objectParameterArray.Length; i++)
    {
        Console.WriteLine("Name: {0} Type: {1} Value: {2}",
            objectParameterArray[i].Name,
            objectParameterArray[i].ParameterType,
            objectParameterArray[i].Value);
    }
}

S’applique à