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)
Parameters
- 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.BooleanReturns true if a parameter with the specified name was found in the collection; otherwise, false.
| Exception | Condition |
|---|---|
| ArgumentNullException | 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 = contactQuery.Parameters; if (objectParameterCollection.Contains("ln")) Console.WriteLine("ln is here"); else Console.WriteLine("ln is not here"); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.