Represents the main entry point for the LINQ to SQL framework.

命名空间:                   

程序集:         System.Data.Linq(位于 System.Data.Linq.dll)

System.Data.Linq.DataContext

语法:

public class DataContext : IDisposable

构造函数:

名称 说明
System_CAPS_pubmethod

Initializes a new instance of the DataContext class by referencing the connection used by the .NET Framework.

System_CAPS_pubmethod

Initializes a new instance of the DataContext class by referencing a connection and a mapping source.

System_CAPS_pubmethod

Initializes a new instance of the DataContext class by referencing a file source.

System_CAPS_pubmethod

Initializes a new instance of the DataContext class by referencing a file source and a mapping source.

属性:

名称 说明
System_CAPS_pubproperty

Gets a collection of objects that caused concurrency conflicts when was called.

System_CAPS_pubproperty

Gets or sets a value that increases the time-out period for queries that would otherwise time out during the default time-out period.

System_CAPS_pubproperty

Gets the connection used by the framework.

System_CAPS_pubproperty

Gets or sets a value that indicates whether to delay-load one-to-many or one-to-one relationships.

System_CAPS_pubproperty

Gets or sets the associated with this DataContext.

System_CAPS_pubproperty

Gets or sets the destination to write the SQL query or command.

System_CAPS_pubproperty

Gets the on which the mapping is based.

System_CAPS_pubproperty

Gets or sets a value that indicates whether object tracking is enabled.

System_CAPS_pubproperty

Gets or sets a local transaction for the .NET Framework to use to access the database.

方法:

名称 说明
System_CAPS_pubmethod

Creates a database on the server.

System_CAPS_protmethod

此 API 支持 产品 基础结构,不应从代码直接使用。      Executes the table-valued database function associated with the specified CLR method.

System_CAPS_pubmethod

Determines whether the associated database can be opened.

System_CAPS_pubmethod

Deletes the associated database.

System_CAPS_pubmethod

Releases all resources used by the current instance of the DataContext class.

System_CAPS_protmethod

Releases the unmanaged resources used by the DataContext class and optionally releases the managed resource.

System_CAPS_pubmethod

Determines whether the specified object is equal to the current object.(继承自 。)

System_CAPS_pubmethod

Executes SQL commands directly on the database.

System_CAPS_protmethod

Executes, inside delete override methods, to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for delete operations.

System_CAPS_protmethod

Executes, inside insert override methods, to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for insert operations.

System_CAPS_protmethod

Executes, inside update override methods, to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for update operations.

System_CAPS_protmethod

此 API 支持 产品 基础结构,不应从代码直接使用。      Executes the stored database procedure or scalar function associated with the specified CLR method.

System_CAPS_pubmethod

Executes SQL queries directly on the database.

System_CAPS_pubmethod

Executes SQL queries directly on the database and returns objects.

System_CAPS_protmethod

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(继承自 。)

System_CAPS_pubmethod

Gets the modified objects tracked by DataContext.

System_CAPS_pubmethod

Gets the information about SQL commands generated by LINQ to SQL.

System_CAPS_pubmethod

Serves as the default hash function.(继承自 。)

System_CAPS_pubmethod

Returns a collection of objects of a particular type, where the type is defined by the type parameter.

System_CAPS_pubmethod

Returns a collection of objects of a particular type, where the type is defined by the TEntity parameter.

System_CAPS_pubmethod

Gets the of the current instance.(继承自 。)

System_CAPS_protmethod

Creates a shallow copy of the current .(继承自 。)

System_CAPS_pubmethod

Refreshes a collection of entity objects according to the specified mode.

System_CAPS_pubmethod

Refreshes an entity object according to the specified mode.

System_CAPS_pubmethod

Refreshes an array of entity objects according to the specified mode.

System_CAPS_pubmethod

Computes the set of modified objects to be inserted, updated, or deleted, and executes the appropriate commands to implement the changes to the database.

System_CAPS_pubmethod

Sends changes that were made to retrieved objects to the underlying database, and specifies the action to be taken if the submission fails.

System_CAPS_pubmethod

Returns a string that represents the current object.(继承自 。)

System_CAPS_pubmethod

Converts an existing to objects.

System_CAPS_pubmethod

Converts an existing to objects.

System_CAPS_pubmethod

Converts an existing to objects.

The DataContext is the source of all entities mapped over a database connection. It tracks changes that you made to all retrieved entities and maintains an "identity cache" that guarantees that entities retrieved more than one time are represented by using the same object instance.

In general, a DataContext instance is designed to last for one "unit of work" however your application defines that term. A DataContext is lightweight and is not expensive to create. A typical LINQ to SQL application creates DataContext instances at method scope or as a member of short-lived classes that represent a logical set of related database operations.

.NET Framework      

自 3.5 起可用
       Windows Phone Silverlight      
自 7.1 起可用

此类型的所有公共静态(Visual Basic 中的        已共享       在 Visual Basic 中)成员都是线程安全的。不保证所有实例成员都是线程安全的。

备注:转自