Share via


DataContext.GetList<T> Method

Returns an object that represents the specified list and is queryable by LINQ (Language Integrated Query).

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

Syntax

'Declaration
Public Overridable Function GetList(Of T) ( _
    listName As String _
) As EntityList(Of T)
'Usage
Dim instance As DataContext
Dim listName As String
Dim returnValue As EntityList(Of T)

returnValue = instance.GetList(listName)
public virtual EntityList<T> GetList<T>(
    string listName
)

Type Parameters

  • T
    The content type of the list items.

Parameters

Return Value

Type: Microsoft.SharePoint.Linq.EntityList<T>
An EntityList<TEntity> that represents the list.

Remarks

The T parameter is defined by a class that is mapped to the list items.

Note

You cannot create a second EntityList<TEntity> object with the same name and T value as one that already exists. But you can have two “Customers” lists if one has list items of type “LocalCustomer” and the other has list items of type “InternationalCustomer” You can also have two lists with the same type of list item, such as “Customer”, provided that they have different names; say “CurrentCustomers” and “InactiveCustomers.”

Examples

The following is an example of GetList<T>(String) in use. For more information on its use, see How to: Query Using LINQ to SharePoint.

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

See Also

Reference

DataContext Class

DataContext Members

Microsoft.SharePoint.Linq Namespace