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.


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

public class DataContext : IDisposable

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.