EntityList<TEntity> Class

Represents a Microsoft SharePoint Foundation list that can be queried with Language Integrated Query (LINQ).

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Linq.EntityList<TEntity>

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

Syntax

'Declaration
<PermissionSetAttribute(SecurityAction.Assert, Name := "FullTrust")> _
Public NotInheritable Class EntityList(Of TEntity) _
    Implements IOrderedQueryable(Of TEntity), IQueryable(Of TEntity),  _
    IEnumerable(Of TEntity), IOrderedQueryable, IQueryable, IEnumerable
'Usage
Dim instance As EntityList(Of TEntity)
[PermissionSetAttribute(SecurityAction.Assert, Name = "FullTrust")]
public sealed class EntityList<TEntity> : IOrderedQueryable<TEntity>, 
    IQueryable<TEntity>, IEnumerable<TEntity>, IOrderedQueryable, IQueryable, 
    IEnumerable

Type Parameters

  • TEntity
    The content type of the list items.

Remarks

This class enables querying over the list; adding, recycling, editing, or deleting list items; and registering detached objects with the change tracking system.

There is no public constructor for the class. An EntityList<TEntity> object is created with the DataContext.GetList<T>(String) method. The object returned by the ScopeToFolder(String, Boolean) method can also be cast to EntityList<TEntity>.

The following example shows how to get a reference to an EntityList<TEntity> object.

EntityList<Announcement> announcements = teamSite.GetList<Announcement>(“Announcements”)
Dim announcements As EntityList(Of Announcement) = teamSite.GetList(Of Announcement)("Announcements")

You derive a class from DataContext and declare read only EntityList<TEntity> properties in it that represent the lists of the Web site. If you do that, you can reference the lists with standard property read syntax.

Examples

The following example shows a declaration of a DataContext-derived class. Below that is an example of a query that references one of the properties without having to call GetList<T>(String).

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");
        }
    }
}
Partial Public Class TeamSiteDataContext
    Inherits DataContext
    ' ctors omitted for readability.

    <List(Name:="Projects")>
    Public ReadOnly Property Projects() As EntityList(Of Item)
        Get
            Return Me.GetList(Of Item)("Projects")
        End Get
    End Property

    <List(Name:="Managers")>
    Public ReadOnly Property Managers() As EntityList(Of Item)
        Get
            Return Me.GetList(Of Item)("Managers")
        End Get
    End Property

    <List(Name:="Team Members")>
    Public ReadOnly Property TeamMembers() As EntityList(Of Item)
        Get
            Return Me.GetList(Of Item)("Team Members")
        End Get
    End Property
End Class
TeamSiteDataContext ourTeamSite = new TeamSiteDataContext(“http://MarketingTeam”);

var vicePresidents = from manager in ourTeamSite.Managers
                     where manager.Rank = “Vice President”
                     select manager;
Dim ourTeamSite As New TeamSiteDataContext("http://MarketingTeam")

Dim vicePresidents = From manager In ourTeamSite.Managers
                     Where manager.Rank = "Vice President"
                     Select manager

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

EntityList<TEntity> Members

Microsoft.SharePoint.Linq Namespace