KDG-Net-Database 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package KDG-Net-Database --version 0.0.2                
NuGet\Install-Package KDG-Net-Database -Version 0.0.2                
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="KDG-Net-Database" Version="0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KDG-Net-Database --version 0.0.2                
#r "nuget: KDG-Net-Database, 0.0.2"                
#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.
// Install KDG-Net-Database as a Cake Addin
#addin nuget:?package=KDG-Net-Database&version=0.0.2

// Install KDG-Net-Database as a Cake Tool
#tool nuget:?package=KDG-Net-Database&version=0.0.2                

Getting started

PostgreSQL

Connecting to the database

  1. Initialize your database connection
var db = new KDG.Database.Database.PostgreSQL("your-connection-string");
  1. Fetch data using withConnection and withTransaction
var data = db.withConnection(async conn => {
  var result = await conn.QueryAsync("select * from table");
  return result;
});

DML Operations

The KDG.Database.Database.PostgreSQL class has corresponding insert, update, and delete methods

  • Insert

  KDG.Database.Database.PostgreSQL.Insert<T>(
    Npgsql.NpgsqlTransaction t,
    KDG.Database.DML.InsertConfig<T> data
  )
  • Update

  KDG.Database.Database.PostgreSQL.Update<T>(
    Npgsql.NpgsqlTransaction t,
    KDG.Database.DML.UpdateConfig<T> data
  )
  • Delete

  KDG.Database.Database.PostgreSQL.Delete<T>(
    Npgsql.NpgsqlTransaction t,
    KDG.Database.DML.DeleteConfig<T> data
  )

Here's what a full example might look like:

var db = new KDG.Database.PostgreSQL("connection-string");
await db.withTransaction(t => {
  db.Insert(
    t,
    new KDG.Database.DML.InsertConfig<UserModel>{
      Table="your-table",
      Data=New UserModel(),
      Fields=new Dictionary<string,Func<UserModel,object>>{
        "id", x => x.id,
        "email", x => x.email
      },
    }
  );
  return true;
})

Support

For support, please open an issue on our GitHub Issues page and provide your questions or feedback. We strive to address all inquiries promptly.

Contributing

To contribute to this project, please follow these steps:

  1. Fork the repository to your own GitHub account.
  2. Make your changes and commit them to your fork.
  3. Submit a pull request to the original repository with a clear description of what your changes do and why they should be included.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.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
0.0.3 86 7/11/2024
0.0.2 70 7/11/2024
0.0.1 93 7/3/2024