다음을 통해 공유


List (SPMetal)

Applies to: SharePoint Foundation 2010

Specifies that a list should be included in code generation and modifies which content types in the list are included in code generation.

Web (SPMetal)
  List (SPMetal)

<List Name="Calendar" Member="ScheduledEvents"> ... </List>

Complex

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

Name (required)

The name of the list in SharePoint Foundation.

Member (optional)

The name SPMetal gives to the property that it generates to represent the list.

Type (optional)

Specifies the return type of the property.

Child Elements

Element

Description

ContentType

Includes a content type for code generation and modifies which fields (columns) in the content type are included in code generation.

ExcludeContentType

Excludes a content type from code generation.

Parent Elements

Element

Description

Web (SPMetal)

Specifies the name and access level (public or internal) of the class (derived from DataContext) that SPMetal generates.

Remarks

A List element cannot have both a ContentType element and an ExcludeContentType element that name the same content type.

Example

The following is an example of a List element in use. If this is a hidden list, the presence of the element ensures that it is included in code generation. The example also contains a ContentType element that ensures that the content type class for the list content type is named "TeamMember" instead of the default "TeamMembersItem".

<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal" xmlns="https://schemas.microsoft.com/SharePoint/2009/spmetal">
  <ContentType Name="Contact" Class="Contact">
    <Column Name="ContId" Member="ContactId" />
    <Column Name="ContactName" Member="ContactName1" />
    <Column Name="Category" Member="Cat" Type="String"/>
    <ExcludeColumn Name="HomeTelephone" />
  </ContentType>
  <ExcludeContentType Name="Order"/>
  <List Name="Team Members">
    <ContentType Name="Item" Class="TeamMember"” />
  </List>
</Web>

See Also

Concepts

SPMetal Default Code Generation Rules

Overriding SPMetal Defaults by Using a Parameters XML File