Partilhar via


DataContext Class

Provides LINQ (Language Integrated Query) access to, and change tracking for, the lists and document libraries of a Microsoft SharePoint Foundation Web site.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Linq.DataContext

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

Syntax

'Declaration
Public Class DataContext _
    Implements IDisposable
'Usage
Dim instance As DataContext
public class DataContext : IDisposable

Remarks

Notes to Inheritors

You can use the existing DataContext class to represent the data of a Web site, but there are advantages to deriving your own class. The SPMetal tool will automatically declare a class derived from DataContext. This class will be marked partial (Partialin Visual Basic) so you can add members to it in a separate code file that is not overwritten whenever SPMetal regenerates code. Also, the class generated by SPMetal will have the signatures of a partial method named OnCreated that is called in the class’s constructors. You can implement OnCreated in the other code file to, for example, initialize members you have declared in that code file.

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

DataContext Members

Microsoft.SharePoint.Linq Namespace