Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
262 lines (226 sloc) 17.4 KB
<Type Name="ObjectParameter" FullName="System.Data.Objects.ObjectParameter">
<TypeSignature Language="C#" Value="public sealed class ObjectParameter" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ObjectParameter extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Data.Objects.ObjectParameter" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ObjectParameter" />
<TypeSignature Language="C++ CLI" Value="public ref class ObjectParameter sealed" />
<TypeSignature Language="F#" Value="type ObjectParameter = class" />
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Represents a query parameter that is passed to an object query.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Represents a query parameter that is passed to an <xref:System.Data.Objects.ObjectQuery%601> or a query builder method. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
Object parameters consist of a name, a type, and a value.
This class cannot be inherited. For more information, see <xref:System.Data.Objects.ObjectParameterCollection>.
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example adds new parameters to the collection. It iterates through the <xref:System.Data.Objects.ObjectParameterCollection> and displays the name, type, and value of each parameter in the collection.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_parameters)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_parameters)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Data.Objects.ObjectParameter" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectParameter (string name, object value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name, object value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectParameter.#ctor(System.String,System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (name As String, value As Object)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ObjectParameter(System::String ^ name, System::Object ^ value);" />
<MemberSignature Language="F#" Value="new System.Data.Objects.ObjectParameter : string * obj -&gt; System.Data.Objects.ObjectParameter" Usage="new System.Data.Objects.ObjectParameter (name, value)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="value" Type="System.Object" />
</Parameters>
<Docs>
<param name="name">The parameter name. This name should not include the "@" parameter marker that is used in [!INCLUDE[esql](~/includes/esql-md.md)] statements, only the actual name. The first character of the expression must be a letter. Any successive characters in the expression must be either letters, numbers, or an underscore (_) character.</param>
<param name="value">The initial value (and inherently, the type) of the parameter.</param>
<summary>Initializes a new instance of the <see cref="T:System.Data.Objects.ObjectParameter" /> class with the specified name and value.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This constructor creates a parameter from the specified name and value. The type of the parameter is inferred from the value.
When added to the <xref:System.Data.Objects.ObjectParameterCollection>, the parameter name cannot be changed. The parameter value can be changed through the <xref:System.Data.Objects.ObjectParameter.Value%2A> property. After the query has been compiled, the value cannot be changed. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example adds new parameters to the collection. It iterates through the <xref:System.Data.Objects.ObjectParameterCollection> and displays the name, the type and the value of each parameter in the collection.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_parameters)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_parameters)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">If the value of either argument is null.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">If the value of the name argument is not valid. Parameter names must start with a letter and can only contain letters, numbers, and underscores.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects and Shaping Results (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectParameter (string name, Type type);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name, class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectParameter.#ctor(System.String,System.Type)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ObjectParameter(System::String ^ name, Type ^ type);" />
<MemberSignature Language="F#" Value="new System.Data.Objects.ObjectParameter : string * Type -&gt; System.Data.Objects.ObjectParameter" Usage="new System.Data.Objects.ObjectParameter (name, type)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="name">The parameter name. This name should not include the "@" parameter marker that is used in the [!INCLUDE[esql](~/includes/esql-md.md)] statements, only the actual name. The first character of the expression must be a letter. Any successive characters in the expression must be either letters, numbers, or an underscore (_) character.</param>
<param name="type">The common language runtime (CLR) type of the parameter.</param>
<summary>Initializes a new instance of the <see cref="T:System.Data.Objects.ObjectParameter" /> class with the specified name and type.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When instantiated, the parameter name cannot be changed. The parameter value can be set or changed through the <xref:System.Data.Objects.ObjectParameter.Value%2A> property. After the query has been compiled, the value cannot be changed. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">If the value of either argument is null.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">If the value of the name argument is invalid. Parameter names must start with a letter and can only contain letters, numbers, and underscores.</exception>
</Docs>
</Member>
<Member MemberName="Name">
<MemberSignature Language="C#" Value="public string Name { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Name" />
<MemberSignature Language="DocId" Value="P:System.Data.Objects.ObjectParameter.Name" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Name As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::String ^ Name { System::String ^ get(); };" />
<MemberSignature Language="F#" Value="member this.Name : string" Usage="System.Data.Objects.ObjectParameter.Name" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the parameter name, which can only be set through a constructor.</summary>
<value>The parameter name, which can only be set through a constructor.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When instantiated, the parameter name cannot be changed. The parameter value can be set or changed through the <xref:System.Data.Objects.ObjectParameter.Value%2A> property. After the query has been compiled, the value cannot be changed. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example adds new parameters to the collection. It iterates through the <xref:System.Data.Objects.ObjectParameterCollection> and displays the name, type, and value of each parameter in the collection.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_parameters)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_parameters)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects and Shaping Results (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="ParameterType">
<MemberSignature Language="C#" Value="public Type ParameterType { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Type ParameterType" />
<MemberSignature Language="DocId" Value="P:System.Data.Objects.ObjectParameter.ParameterType" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property ParameterType As Type" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property Type ^ ParameterType { Type ^ get(); };" />
<MemberSignature Language="F#" Value="member this.ParameterType : Type" Usage="System.Data.Objects.ObjectParameter.ParameterType" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Type</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the parameter type.</summary>
<value>The <see cref="T:System.Type" /> of the parameter.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The parameter type can only be set through a constructor.
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example adds new parameters to the collection. It iterates through the <xref:System.Data.Objects.ObjectParameterCollection> and displays the name, type, and value of each parameter in the collection.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_parameters)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_parameters)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects and Shaping Results (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Value">
<MemberSignature Language="C#" Value="public object Value { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance object Value" />
<MemberSignature Language="DocId" Value="P:System.Data.Objects.ObjectParameter.Value" />
<MemberSignature Language="VB.NET" Value="Public Property Value As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Object ^ Value { System::Object ^ get(); void set(System::Object ^ value); };" />
<MemberSignature Language="F#" Value="member this.Value : obj with get, set" Usage="System.Data.Objects.ObjectParameter.Value" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the parameter value.</summary>
<value>The parameter value.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
After the query has been compiled, the value cannot be changed. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
If the new value is incompatible with the type declared in the constructor, it might cause a run-time exception. The provider must determine whether the value is compatible with the declared type. For example, if the initial type is <xref:System.Int32> and the new value is <xref:System.Guid>, you might receive an exception.
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example adds new parameters to the collection. It iterates through the <xref:System.Data.Objects.ObjectParameterCollection> and displays the name, the type and the value of each parameter in the collection.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_parameters)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Parameters](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_parameters)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects and Shaping Results (Entity Framework)</related>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.