UsePeriodicPasswordProvider() // Automatically rotate the password periodicallyĪwait using var dataSource = dataSourceBuilder.Build() įor more information on data source configuration, consult the relevant documentation pages. UseNodaTime() // Use NodaTime for date/time types UseLoggerFactory(loggerFactory) // Configure logging To further configure a data source, use NpgsqlDataSourceBuilder as follows: var dataSourceBuilder = new NpgsqlDataSourceBuilder("Host=localhost Username=test Password=test") Npgsql's data source supports additional configuration beyond the connection string, such as logging, advanced authentication options, type mapping management, and more. The connection string consists of key/value pairs, separated with semicolons many options are supported in Npgsql, these are documented on the connection string page. In this code, a data source is created given a connection string, which is used to define which database to connect to, the authentication information to use, and various other connection-related parameters. The simplest way to create a data source is the following: var connectionString = "Host=myserver Username=mylogin Password=mypass Database=mydatabase" Īwait using var dataSource = NpgsqlDataSource.Create(connectionString) The data source encapsulates the various Npgsql configuration needed to connect to PostgreSQL, as well the connection pooling which makes Npgsql efficient. The data source represents your PostgreSQL database, and can hand out connections to it, or support direct execution of SQL against it. Starting with Npgsql 7.0, the starting point for any database operation is NpgsqlDataSource. If you're using an older version, see Connections without a data source below. The data source concept was introduced in Npgsql 7.0.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |