ObjectParameter Class
Represents a query parameter that is passed to an object query.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
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.
Using advWorksContext As New AdventureWorksEntities Try Dim queryString As String = _ "SELECT VALUE Contact FROM AdventureWorksEntities.Contact " & _ "AS Contact WHERE Contact.LastName = @ln " & _ "AND Contact.FirstName = @fn" Dim contactQuery As New ObjectQuery(Of Contact)(queryString, _ advWorksContext) ' 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. Dim result As ObjectParameter For Each result In DirectCast(objectParameterCollection, _ IEnumerable(Of ObjectParameter)) Console.WriteLine("{0} {1} {2}", result.Name, _ result.Value, result.ParameterType) Next Catch ex As EntitySqlException Console.WriteLine(ex.ToString) End Try End Using
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.