ListAttribute Class

Specifies that a property of a DataContext object represents a Microsoft SharePoint Foundation list.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.SharePoint.Linq.ListAttribute

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

Syntax

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

Examples

For example, the following shows a simplified declaration of a DataContext-derived class that has several properties that represent lists:

public partial class TeamSiteDataContext : DataContext 
{
    // ctors omitted for readability.
    
    [List(Name="Projects")]
    public EntityList<Item> Projects 
    {
        get {
            return this.GetList<Item>("Projects");
        }
    }
    
    [List(Name="Managers")]
    public EntityList<Item> Managers 
    {
        get {
            return this.GetList<Item>("Managers");
        }
    }
    
    [List(Name="Team Members")]
    public EntityList<Item> TeamMembers 
    {
        get {
            return this.GetList<Item>("Team Members");
        }
    }
}

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

ListAttribute Members

Microsoft.SharePoint.Linq Namespace