Condividi tramite


ContentTypeAttribute Class

Specifies that the class maps to a Microsoft SharePoint Foundation content type.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.SharePoint.Linq.ContentTypeAttribute

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False)> _
Public NotInheritable Class ContentTypeAttribute _
    Inherits Attribute
'Usage
Dim instance As ContentTypeAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)]
public sealed class ContentTypeAttribute : Attribute

Remarks

The content type being represented need not be a defined content type on the SharePoint Foundation Web site. When a site owner adds a column to an existing list, he creates a new implicit content type. That kind of implicit content type is also represented by classes decorated with a ContentTypeAttribute.

Examples

The following is an example of a ContentTypeAttribute used to map a TeamMembersItem class to the content type of a Team Members list.

[ContentType(Name="Item", Id="0x01", List="Team Members")]
[DataContract()]
public partial class TeamMembersItem : Item {

    // Member declarations omitted.
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ContentTypeAttribute Members

Microsoft.SharePoint.Linq Namespace