Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Contains Method (String)
Collapse the table of content
Expand the table of content

ObjectParameterCollection.Contains Method (String)

Determines whether an ObjectParameter with the specified name is in the collection.

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

public bool Contains(
	string name


Type: System.String

The name of the parameter to look for in the collection. This name should not include the "@" parameter marker that is used in the Entity SQL statements, only the actual name.

Return Value

Type: System.Boolean
Returns true if a parameter with the specified name was found in the collection; otherwise, false.


The name parameter is null.

The example in this topic is based on the Adventure Works Sales Model. The example uses the Contains method to determine whether the specified parameter is 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 =

    if (objectParameterCollection.Contains("ln"))
        Console.WriteLine("ln is here");
        Console.WriteLine("ln is not here");

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4
© 2015 Microsoft