ObjectParameter.ParameterType 属性

定义

获取参数类型。

public:
 property Type ^ ParameterType { Type ^ get(); };
public Type ParameterType { get; }
member this.ParameterType : Type
Public ReadOnly Property ParameterType As Type

属性值

参数的 Type

示例

此示例将新参数添加到集合。 它循环访问 ObjectParameterCollection 并显示集合中每个参数的名称、类型和值。

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);
    }
}

注解

参数类型只能通过构造函数进行设置。

适用于

另请参阅