DataContext Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
The data context is an object representing the database, a proxy, containing Table objects that represent the tables in the database.
Inheritance Hierarchy
System.Object
System.Data.Linq.DataContext
Namespace: System.Data.Linq
Assembly: System.Data.Linq (in System.Data.Linq.dll)
Syntax
'Declaration
Public Class DataContext _
Implements IDisposable
public class DataContext : IDisposable
The DataContext type exposes the following members.
Constructors
Name | Description | |
---|---|---|
DataContext(String) | Initializes a new instance of the DataContext class by referencing a file source. | |
DataContext(String, MappingSource) | Initializes a new instance of the DataContext class by referencing a file source and a mapping source. |
Top
Properties
Name | Description | |
---|---|---|
ChangeConflicts | Returns a collection of objects that caused concurrency conflicts when SubmitChanges was called. | |
DeferredLoadingEnabled | Specifies whether to delay-load one-to-many or one-to-one relationships. | |
LoadOptions | Gets or sets the DataLoadOptions associated with this DataContext. | |
Log | Specifies the destination to write the SQL query or command. | |
Mapping | Returns the MetaModel on which the mapping is based. | |
ObjectTrackingEnabled | Instructs the framework to track the original value and object identity for this DataContext. |
Top
Methods
Name | Description | |
---|---|---|
CreateDatabase | Creates a database. | |
DatabaseExists | Determines whether the associated database can be opened. | |
DeleteDatabase | Deletes the associated database. | |
Dispose() | Releases all resources used by the DataContext. | |
Dispose(Boolean) | Releases resources used by the DataContext. | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
ExecuteDynamicDelete | Called inside delete override methods to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for delete operations. | |
ExecuteDynamicInsert | Called inside insert override methods to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for insert operations. | |
ExecuteDynamicUpdate | Called inside update override methods to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for update operations. | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetChangeSet | Provides access to the modified objects tracked by DataContext. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetTable(Type) | Returns a collection of objects of a particular type, where the type is defined by the type parameter. | |
GetTable<TEntity>() | Returns a collection of objects of a particular type, where the type is defined by the TEntity parameter. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Refresh(RefreshMode, IEnumerable) | Refreshes a collection of entity objects according to the specified mode. | |
Refresh(RefreshMode, Object) | Refreshes an entity object according to the specified mode. | |
Refresh(RefreshMode, array<Object[]) | Refreshes an array of entity objects according to the specified mode. | |
SubmitChanges() | Computes the set of modified objects to be inserted, updated, or deleted, and executes the appropriate commands to implement the changes to the database. | |
SubmitChanges(ConflictMode) | Sends changes that were made to retrieved objects to the underlying database, and specifies the action to be taken if the submission fails. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Extension Methods
Name | Description | |
---|---|---|
CreateDatabaseSchemaUpdater | Creates a DatabaseSchemaUpdater object based on the specified data context. (Defined by Extensions.) |
Top
Remarks
For information about using a local database in your Windows Phone application, see Local Database Overview for Windows Phone.
Topic | Location |
---|---|
External Mapping Reference (LINQ to SQL) | LINQ to SQL |
Frequently Asked Questions (LINQ to SQL) | LINQ to SQL |
ADO.NET and LINQ to SQL | LINQ to SQL |
Object States and Change-Tracking (LINQ to SQL) | LINQ to SQL |
How to: Reuse a Connection Between an ADO.NET Command and a DataContext (LINQ to SQL) | LINQ to SQL |
How to: Connect to a Database (LINQ to SQL) | LINQ to SQL |
Object Identity (LINQ to SQL) | LINQ to SQL |
External Mapping Reference (LINQ to SQL) | LINQ to SQL |
Frequently Asked Questions (LINQ to SQL) | LINQ to SQL |
ADO.NET and LINQ to SQL | LINQ to SQL |
Object States and Change-Tracking (LINQ to SQL) | LINQ to SQL |
How to: Reuse a Connection Between an ADO.NET Command and a DataContext (LINQ to SQL) | LINQ to SQL |
How to: Connect to a Database (LINQ to SQL) | LINQ to SQL |
Object Identity (LINQ to SQL) | LINQ to SQL |
Version Information
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
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.