Web (SPMetal)

Applies to: SharePoint Foundation 2010

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

For information about the default behavior of SPMetal when an optional element or attribute is not present, see SPMetal Default Code Generation Rules.

Web (SPMetal)

<Web Class="TeamSite" AccessModifier="Internal"> ... </Web>

Complex

Attributes and Elements

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

Attributes

Attribute

Description

Class (optional)

Specifies a name for the class (derived from DataContext) that SPMetal generates.

AccessModifier (optional)

Specifies whether the class (derived from DataContext) is public or internal.

AccessModifier Attribute Possible Values:

Value

Description

Internal

The class will be internal (Friend in Visual Basic).

Public

DEFAULT: The class will be public (Public in Visual Basic).

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.

ExcludeOtherContentTypes

Excludes from code generation all content types not explicitly included in a ContentType element.

IncludeHiddenContentTypes

Includes hidden content types in code generation.

List

Includes a list for code generation and modifies which content types in the list are included in code generation.

ExcludeList

Excludes a list from code generation.

ExcludeOtherLists

Excludes from code generation all lists not explicitly included in a List element.

IncludeHiddenLists

Includes hidden lists in code generation.

Parent Elements

Element

Description

None

Remarks

A Web element cannot have both a ContentType element and an ExcludeContentType element that name the same content type. An ExcludeContentType element that names a hidden content type may not be present in the same Web element that has an IncludeHiddenContentTypes element. Finally, a Web element cannot have both an ExcludeOtherContentTypes element and an IncludeHiddenContentTypes element.

Example

The following is an example of a Web element.

<?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" Type="TeamMember">
    <ContentType Name="Item" Class="TeamMember" />
  </List>
</Web>

See Also

Concepts

SPMetal Default Code Generation Rules

Overriding SPMetal Defaults by Using a Parameters XML File