SqlServerDataContext.SqlServerDataContext(SqlConnection dbConnection) Constructor
.NET Standard 2.x
Initializes a new instance of the SqlServerDataContext class by passing the SqlConnection
type object as a parameter.
Namespace: SnapObjects.Data.SqlServer
Assembly: SnapObjects.Data.SqlServer.dll
Syntax
public SqlServerDataContext(SqlConnection dbConnection) : base(dbConnection, new SqlServerDataContextOptions(String.Empty))
Parameters
dbConnection
SqlConnection
The connection object which is a SqlConnection
instance.
Examples
The following code example uses a SqlServerConnection
object to initialize an instance of the SqlServerDataContext
class.
using Appeon.ApiDoc.Models;
using SqlServer.ManagedDataAccess.Client;
using SnapObjects.Data;
using SnapObjects.Data.SqlServer;
using System;
namespace Appeon.ApiDoc.SqlServerDataContextExamples
{
public class SqlServerDataContextExample
{
public void Example2()
{
DataContext dataContext = new SqlServerDataContext(new SqlServerConnection(CONNECTION_STRING));
Console.WriteLine(dataContext.ContextOptions.DatabaseType);
/*This code produces the following output:
SqlServer
*/
}
}
}
Applies to
.NET Standard
2.x