forked from dotnet/dotnet-api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMetadataTypeAttribute.xml
183 lines (165 loc) · 11.3 KB
/
MetadataTypeAttribute.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<Type Name="MetadataTypeAttribute" FullName="System.ComponentModel.DataAnnotations.MetadataTypeAttribute">
<TypeSignature Language="C#" Value="public sealed class MetadataTypeAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit MetadataTypeAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.ComponentModel.DataAnnotations.MetadataTypeAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class MetadataTypeAttribute
Inherits Attribute" />
<TypeSignature Language="F#" Value="type MetadataTypeAttribute = class
 inherit Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class MetadataTypeAttribute sealed : Attribute" />
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.3.0.0</AssemblyVersion>
<AssemblyVersion>4.3.1.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-3.0;netcore-3.1;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Specifies the metadata class to associate with a data model class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.ComponentModel.DataAnnotations.MetadataTypeAttribute> attribute enables you to associate a class with a data-model partial class. In this associated class you provide additional metadata information that is not in the data model.
For example, in the associated class you can apply the <xref:System.ComponentModel.DataAnnotations.RequiredAttribute> attribute to a data field. This enforces that a value is provided for the field even if this constraint is not required by the database schema.
You use the <xref:System.ComponentModel.DataAnnotations.MetadataTypeAttribute> attribute as follows:
- In your application, create a file in which you create the data-model partial class that you want to modify.
- Create the associated metadata class.
- Apply the <xref:System.ComponentModel.DataAnnotations.MetadataTypeAttribute> attribute to the partial entity class, specifying the associated class.
When you apply this attribute, you must adhere to the following usage constraints:
- The attribute can only be applied to a class.
- The attribute cannot be inherited by derived classes.
- The attribute can be applied only one time.
## Examples
The following example shows how to use the <xref:System.ComponentModel.DataAnnotations.MetadataTypeAttribute> to associate a metadata class with an entity partial class. The example applies the <xref:System.ComponentModel.DataAnnotations.RequiredAttribute> attribute to a data field to show how to provide additional information in the associated metadata class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.MetadataTypeAttribute/CS/Customer.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.MetadataTypeAttribute/VB/Customer.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public MetadataTypeAttribute (Type metadataClassType);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Type metadataClassType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.DataAnnotations.MetadataTypeAttribute.#ctor(System.Type)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (metadataClassType As Type)" />
<MemberSignature Language="F#" Value="new System.ComponentModel.DataAnnotations.MetadataTypeAttribute : Type -> System.ComponentModel.DataAnnotations.MetadataTypeAttribute" Usage="new System.ComponentModel.DataAnnotations.MetadataTypeAttribute metadataClassType" />
<MemberSignature Language="C++ CLI" Value="public:
 MetadataTypeAttribute(Type ^ metadataClassType);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.3.0.0</AssemblyVersion>
<AssemblyVersion>4.3.1.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="metadataClassType" Type="System.Type">
<Attributes>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="metadataClassType">The metadata class to reference.</param>
<summary>Initializes a new instance of the <see cref="T:System.ComponentModel.DataAnnotations.MetadataTypeAttribute" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.ComponentModel.DataAnnotations.MetadataTypeAttribute> to associate a metadata class with an entity partial class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.MetadataTypeAttribute/CS/Customer.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.MetadataTypeAttribute/VB/Customer.vb" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="metadataClassType" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="MetadataClassType">
<MemberSignature Language="C#" Value="public Type MetadataClassType { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Type MetadataClassType" />
<MemberSignature Language="DocId" Value="P:System.ComponentModel.DataAnnotations.MetadataTypeAttribute.MetadataClassType" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property MetadataClassType As Type" />
<MemberSignature Language="F#" Value="member this.MetadataClassType : Type" Usage="System.ComponentModel.DataAnnotations.MetadataTypeAttribute.MetadataClassType" />
<MemberSignature Language="C++ CLI" Value="public:
 property Type ^ MetadataClassType { Type ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.3.0.0</AssemblyVersion>
<AssemblyVersion>4.3.1.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Type</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the metadata class that is associated with a data-model partial class.</summary>
<value>The type value that represents the metadata class.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>