Export (0) Print
Expand All

ObjectParameterCollection.Count Property

Gets the number of parameters currently in the collection.

Namespace:  System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public int Count { get; }

Property Value

Type: System.Int32
The number of ObjectParameter objects that are currently in the collection.

Implements

ICollection<T>.Count

The example in this topic is based on the Adventure Works Sales Model. The example adds new parameters to the collection and gets the count of the parameters in the collection. 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;

    Console.WriteLine("Count is {0}.", objectParameterCollection.Count);

    // Iterate through the ObjectParameterCollection collection.
    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 not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), 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.

Community Additions

ADD
Show:
© 2014 Microsoft