DataContext DataContext DataContext DataContext Constructors

Definition

Overloads

DataContext(IDbConnection) DataContext(IDbConnection) DataContext(IDbConnection) DataContext(IDbConnection)

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

DataContext(IDbConnection, MappingSource) DataContext(IDbConnection, MappingSource) DataContext(IDbConnection, MappingSource) DataContext(IDbConnection, MappingSource)

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

DataContext(String, MappingSource) DataContext(String, MappingSource) DataContext(String, MappingSource) DataContext(String, MappingSource)

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

DataContext(String) DataContext(String) DataContext(String) DataContext(String)

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

DataContext(IDbConnection) DataContext(IDbConnection) DataContext(IDbConnection) DataContext(IDbConnection)

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

public:
 DataContext(System::Data::IDbConnection ^ connection);
public DataContext (System.Data.IDbConnection connection);
new System.Data.Linq.DataContext : System.Data.IDbConnection -> System.Data.Linq.DataContext
Public Sub New (connection As IDbConnection)

Parameters

connection
IDbConnection IDbConnection IDbConnection IDbConnection

The connection used by the .NET Framework.

Remarks

A DataContext opens and closes a database connection as needed if you provide a closed connection or a connection string. In general, you should never have to call Dispose on a DataContext. If you provide an open connection, the DataContext will not close it. Therefore, do not instantiate a DataContext with an open connection unless you have a good reason to do this. In a System.Transactions transaction, a DataContext will not open or close a connection to avoid promotion.

DataContext(IDbConnection, MappingSource) DataContext(IDbConnection, MappingSource) DataContext(IDbConnection, MappingSource) DataContext(IDbConnection, MappingSource)

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

public:
 DataContext(System::Data::IDbConnection ^ connection, System::Data::Linq::Mapping::MappingSource ^ mapping);
public DataContext (System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mapping);
new System.Data.Linq.DataContext : System.Data.IDbConnection * System.Data.Linq.Mapping.MappingSource -> System.Data.Linq.DataContext
Public Sub New (connection As IDbConnection, mapping As MappingSource)

Parameters

connection
IDbConnection IDbConnection IDbConnection IDbConnection

The connection used by the .NET Framework.

mapping
MappingSource MappingSource MappingSource MappingSource

A source for mapping.

DataContext(String, MappingSource) DataContext(String, MappingSource) DataContext(String, MappingSource) DataContext(String, MappingSource)

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

public:
 DataContext(System::String ^ fileOrServerOrConnection, System::Data::Linq::Mapping::MappingSource ^ mapping);
public DataContext (string fileOrServerOrConnection, System.Data.Linq.Mapping.MappingSource mapping);
new System.Data.Linq.DataContext : string * System.Data.Linq.Mapping.MappingSource -> System.Data.Linq.DataContext
Public Sub New (fileOrServerOrConnection As String, mapping As MappingSource)

Parameters

fileOrServerOrConnection
String String String String

This argument can be any one of the following:

The name of a file where a SQL Server Express database resides.

The name of a server where a database is present. In this case the provider uses the default database for a user.

A complete connection string. LINQ to SQL just passes the string to the provider without modification.

mapping
MappingSource MappingSource MappingSource MappingSource

A source for mapping.

DataContext(String) DataContext(String) DataContext(String) DataContext(String)

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

public:
 DataContext(System::String ^ connectionString);
public DataContext (string connectionString);
new System.Data.Linq.DataContext : string -> System.Data.Linq.DataContext
Public Sub New (connectionString As String)

Parameters

fileOrServerOrConnection
String String String String

This argument can be any one of the following: The name of a file where a SQL Server Express database resides.

The name of a server where a database is present. In this case the provider uses the default database for a user.

A complete connection string. LINQ to SQL just passes the string to the provider without modification.

Applies to