elideus-dot-net-framework-database-postgresql 2.1.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package elideus-dot-net-framework-database-postgresql --version 2.1.0
                    
NuGet\Install-Package elideus-dot-net-framework-database-postgresql -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="elideus-dot-net-framework-database-postgresql" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="elideus-dot-net-framework-database-postgresql" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="elideus-dot-net-framework-database-postgresql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add elideus-dot-net-framework-database-postgresql --version 2.1.0
                    
#r "nuget: elideus-dot-net-framework-database-postgresql, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package elideus-dot-net-framework-database-postgresql@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=elideus-dot-net-framework-database-postgresql&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=elideus-dot-net-framework-database-postgresql&version=2.1.0
                    
Install as a Cake Tool

Elideus | DotNet Framework Database | PostgreSql

PostgreSql is a subpackage of the Database Package, and provides the basic functionalities required to interact with a PostgreSQL database.

This package includes a class called NpgsqlDatabaseProvider which implements the IDatabaseProvider interface.

It also includes four methods that can be overridden by any project using this package:

  • ExecuteReadMultiple: Reads multiple entries from the database.
  • ExecuteRead: Reads a single entry from the database.
  • ExecuteWrite: Executes an update against the database.
  • MapDataReader: Used to map the NpgsqlDataReader to the desired type.

Database Provider

To use this package, you need to create a provider for each table. That provider must inherit from NpgsqlDatabaseProvider.

The provider must specify a type parameter, representing the table model. For example, suppose we have a users table:

public class UserTable
{
    public required string Username { get; set; }

    public required string Password { get; set; }
}

You then define an interface for the provider extending IDatabaseProvider<UserTable>:

public interface IDatabaseUserProvider : IDatabaseProvider<UserTable>
{
}

The IDatabaseProvider interface already defines several methods, so your custom interface can define any new methods specific to your application.

Finally, implement the interface by extending NpgsqlDatabaseProvider:

public class DatabaseUserProvider : NpgsqlDatabaseProvider<UserTable>, IDatabaseUserProvider
{
}

Now the provider is ready to be registered and used as a dependency in your application.


Database Interaction Examples

CreateTableIfNotExists

public override bool CreateTableIfNotExists()
{
    var command = $"CREATE TABLE IF NOT EXISTS {UserTable.TABLE_NAME}" +
                  $"(" +
                  $"{UserTable.COLUMN_ID} VARCHAR(64) NOT NULL," +
                  $"{UserTable.COLUMN_PASSWORD} VARCHAR(28) NOT NULL," +
                  $"PRIMARY KEY ({UserTable.COLUMN_ID})" +
                  $")";

    return ExecuteWrite(connectionString, command);
}

GetAll

public override List<UserTable> GetAll()
{
    var command = $"SELECT * FROM {UserTable.TABLE_NAME}";

    return ExecuteReadMultiple(connectionString, command);
}

GetById

public override UserTable? GetById(string id)
{
    var command = $"SELECT * FROM {UserTable.TABLE_NAME} WHERE {UserTable.COLUMN_ID} = '{id}'";

    return ExecuteRead(connectionString, command);
}

Add

public override bool Add(UserTable user)
{
    var command = $"INSERT INTO {UserTable.TABLE_NAME} " +
                  $"({UserTable.COLUMN_ID}, {UserTable.COLUMN_PASSWORD}) VALUES " +
                  $"('{user.Id}', '{user.Password}');";

    return ExecuteWrite(connectionString, command);
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated