List (SPMetal)

Last modified: July 15, 2011

Applies to: SharePoint Foundation 2013 | SharePoint Server 2013

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

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.

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

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="http://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>

Show:
© 2014 Microsoft