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>


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




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




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


Excludes a content type from code generation.

Parent elements



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="">
  <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" />
  <ExcludeContentType Name="Order"/>
  <List Name="Team Members">
    <ContentType Name="Item" Class="TeamMember"” />