KDG-Net-Database
0.0.2
There is a newer version of this package available.
See the version list below for details.
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Getting started
PostgreSQL
Connecting to the database
- Initialize your database connection
var db = new KDG.Database.Database.PostgreSQL("your-connection-string");
- Fetch data using
withConnection
andwithTransaction
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:
- Fork the repository to your own GitHub account.
- Make your changes and commit them to your fork.
- Submit a pull request to the original repository with a clear description of what your changes do and why they should be included.
Product | Versions 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.
-
net8.0
- Dapper (>= 2.1.35)
- NodaTime (>= 3.1.9)
- NodaTime.Serialization.JsonNet (>= 3.0.1)
- NodaTime.Serialization.SystemTextJson (>= 1.0.0)
- Npgsql (>= 8.0.3)
- Npgsql.NodaTime (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.