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