ObjectParameter.ParameterType Propriedade
Definição
Obtém o tipo de parâmetro.Gets the parameter type.
public:
property Type ^ ParameterType { Type ^ get(); };
public Type ParameterType { get; }
member this.ParameterType : Type
Public ReadOnly Property ParameterType As Type
Valor da propriedade
O Type do parâmetro.The Type of the parameter.
Exemplos
O exemplo neste tópico é baseado no Microsoft SQL Server exemplos de produto: banco de dados.The example in this topic is based on the Microsoft SQL Server Product Samples: Database. O exemplo adiciona novos parâmetros à coleção.The example adds new parameters to the collection. Ele itera através de ObjectParameterCollection e exibe o nome, o tipo e o valor de cada parâmetro na coleção.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;
// Iterate through the ObjectParameterCollection.
foreach (ObjectParameter result in objectParameterCollection)
{
Console.WriteLine("{0} {1} {2}", result.Name,
result.Value,
result.ParameterType);
}
}
Using context As New AdventureWorksEntities()
Dim queryString As String = "SELECT VALUE contact FROM AdventureWorksEntities.Contacts" & _
" AS contact WHERE contact.LastName = @ln AND contact.FirstName = @fn"
Dim contactQuery As New ObjectQuery(Of Contact)(queryString, context)
' 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.
For Each result As ObjectParameter In objectParameterCollection
Console.WriteLine("{0} {1} {2}", result.Name, result.Value, result.ParameterType)
Next
End Using
Comentários
O tipo de parâmetro só pode ser definido por meio de um construtor.The parameter type can only be set through a constructor.