Microsoft.SharePoint.Linq namespace
Provides the classes that implement the LINQ to SharePoint provider.
The main gateway class that provides access to the Microsoft SharePoint Foundation is DataContext which provides for LINQ querying, writing to the content databases, and object change management. Its two most important method are GetList<T>(String), which returns the queryable EntityList<TEntity> object that represents a list, and SubmitChanges(), which writes changes to the content database.
The namespace also provides a set of “entity classes” that represent list items and field values and which, together with EntityList<TEntity> provide an object-relational mapping and interface between your object-oriented .Net code and the relational structure of the content databases. The other principal entity classes are EntityRef<TEntity>, EntitySet<TEntity>, and LookupList<T>. The first two of these implement deferred loading; so the constructor of an EntityList<TEntity> does not have to load entity objects from its entity associations. Each field in a list item is loaded only when it is first referenced in post-constructor code.
To facilitate the object-relational mapping, a rich set of attribute classes are provided. The most important of these are ContentTypeAttribute, which decorates a class that represents the content type of a list, ColumnAttribute, which decorates a property that represents a column (field) in a list, and AssociationAttribute, which decorates properties which represent a lookup relationship between a column in one list and a column in another.
LINQ to SharePoint enables writing to the content databases using optimistic concurrency. This requires a system for tracking changes to objects, detecting concurrency conflicts, and resolving those conflicts. Several classes are provided to support this system including ITrackEntityState, ObjectChangeConflict, and MemberChangeConflict.
Finally, the ICustomMapping interface provides a means of extending an already deployed SharePoint Foundation solution to handle columns added to a list after the initial deployment without requiring recompilation of the original solution assemblies or even redeployment of them.
Note
The namespace also contains two public classes needed to enable querying SharePoint Foundation lists with ADO.NET Data Services. These are not documented because they should not be called from your code.
Classes
Class | Description | |
---|---|---|
AssociationAttribute | Specifies that the property (mapped to a list field) has an association to another list, such as when the property is mapped to a lookup field. | |
AssociationChangedEventArgs<T> | Provides data for the OnChanged event of EntityRef<TEntity>, EntitySet<TEntity>, or Microsoft.SharePoint.Linq.LookupList<T>. | |
ChangeConflictCollection | Represents a collection of ObjectChangeConflict objects. | |
ChangeConflictException | Represents the exception that is thrown when an update fails because database values have been updated since the client last read them. | |
ChoiceAttribute | Maps a member of an enumeration to a String choice value for a Choice or MultiChoice type field on a Microsoft SharePoint Foundation list. | |
ColumnAttribute | Specifies that the property is mapped to a field (column) in a Microsoft SharePoint Foundation list. | |
ContentTypeAttribute | Specifies that the class maps to a Microsoft SharePoint Foundation content type. | |
CustomMappingAttribute | Identifies what new columns are mapped with the MapFrom(Object) method that is decorated with the attribute. | |
DataAttribute | Provides two optional properties commonly used by attributes on properties (of entity classes) that are mapped to list fields (columns) or list properties. | |
DataContext | Provides LINQ (Language Integrated Query) access to, and change tracking for, the lists and document libraries of a Microsoft SharePoint Foundation Web site. | |
DerivedEntityClassAttribute | Identifies a class that derives from the class to which the attribute is applied. | |
EntityList<TEntity> | Represents a Microsoft SharePoint Foundation list that can be queried with Language Integrated Query (LINQ). | |
EntityRef<TEntity> | Provides for deferred loading and relationship maintenance for the singleton side of a one-to-many relationship. | |
EntitySet<TEntity> | Provides for deferred loading and relationship maintenance for the “many” side of one-to-many and many-to-many relationships | |
ListAttribute | Specifies that a property of a DataContext object represents a Microsoft SharePoint Foundation list. | |
LookupList<T> | Represents the values of a Microsoft SharePoint Foundation lookup field (column) that allows multiple values. | |
MemberChangeConflict | Specifies information about a discrepancy between the value of a field (or list item metadata property) in the database and its value in the current process on the front-end Web server - its client value. | |
ObjectChangeConflict | Specifies information about discrepancies between the current client value of one or more fields in a list item and the current database values of the fields. | |
RemovedColumnAttribute | Specifies that the property maps to a field (column) that is on the parent content type but was removed from the derived content type. | |
ResourceStrings | This type or member supports Microsoft Windows SharePoint Services and is not intended to be used directly from your code. | |
Utility | Provides miscellaneous functionality to the LINQ to SharePoint provider. |
Interfaces
Interface | Description | |
---|---|---|
ICustomMapping | Enables extension of the object-relational mapping system of the LINQ to SharePoint provider. | |
ITrackEntityState | Enables participation in the object tracking system of the LINQ to SharePoint provider. | |
ITrackOriginalValues | Enables implementing classes to store a dictionary of changed properties and their original values. |
Enumerations
Enumeration | Description | |
---|---|---|
AssociationChangedState | Specifies how an EntityRef<TEntity>, EntitySet<TEntity>, or Microsoft.SharePoint.Linq.LookupList<T> changes. | |
AssociationType | Specifies the type of lookup relation between a field (column) in one list and a field in another list. | |
ConflictMode | Specifies when an attempt to submit changes to a list should be stopped and a ChangeConflictException thrown. | |
EntityState | Records the changed state of an entity (usually a list item; but possibly a detached entity). | |
RefreshMode | Specifies how the list item changing system of the LINQ to SharePoint provider will respond when it finds that a list item has been changed by another process since it was retrieved. |