IceCoffee.Db4Net.DependencyInjection
1.2.2
dotnet add package IceCoffee.Db4Net.DependencyInjection --version 1.2.2
NuGet\Install-Package IceCoffee.Db4Net.DependencyInjection -Version 1.2.2
<PackageReference Include="IceCoffee.Db4Net.DependencyInjection" Version="1.2.2" />
<PackageVersion Include="IceCoffee.Db4Net.DependencyInjection" Version="1.2.2" />
<PackageReference Include="IceCoffee.Db4Net.DependencyInjection" />
paket add IceCoffee.Db4Net.DependencyInjection --version 1.2.2
#r "nuget: IceCoffee.Db4Net.DependencyInjection, 1.2.2"
#:package IceCoffee.Db4Net.DependencyInjection@1.2.2
#addin nuget:?package=IceCoffee.Db4Net.DependencyInjection&version=1.2.2
#tool nuget:?package=IceCoffee.Db4Net.DependencyInjection&version=1.2.2
IceCoffee.Db4Net
| Package | NuGet Stable | Downloads |
|---|---|---|
| IceCoffee.Db4Net | ||
| IceCoffee.Db4Net.DependencyInjection |
Description
A simple and performant SQL builder and runner for Dapper, using a fluent API and string interpolation to build safe and dynamic SQL queries.
Quick Start
Below are a few common ways to configure and use IceCoffee.Db4Net. For more detailed examples, see the project documentation.
1) Quick (static facade)
using IceCoffee.Db4Net;
using IceCoffee.Db4Net.Core;
// register default database (convenience API)
Db.Register(DatabaseProvider.SQLite, "Data Source=sample.db");
// configure global options (parameter name prefix, reuse flags, etc.)
Db.Configure(new Db4NetSettings { ParameterNamePrefix = "p_", ReuseParameters = true });
// use static facade builders
var foo = Db.Query<Foo>(1).GetSingleOrDefault();
2) Recommended (Dependency Injection)
// Program.cs / Startup.cs
builder.Services.AddDbConnection<MyRepository>(options =>
{
options.DatabaseProvider = DatabaseProvider.SQLite;
options.ConnectionString = configuration.GetConnectionString("Default");
});
// later: inject `MyRepository` where needed
3) Tests or isolated scenarios (local registry)
// create an isolated registry (useful for tests)
var registry = Db.CreateDatabaseRegistry();
registry.Configure(Db.Registry.Settings);
registry.Register(DatabaseProvider.SQLite, "Data Source=InMemorySample;Mode=Memory;Cache=Shared");
var repo = new Repository(registry, string.Empty);
Note: The library exposes a global Db.Registry for convenience, but DI or local registries are recommended for applications and tests to avoid shared mutable state.
Share Your Feedback
If you like the library, use it, share it, and give it a ⭐️. For any suggestions, feature requests, or issues feel free to create an issue to help improve the library.
License
This project is licensed under the MIT License. See the LICENSE file for details.
| 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. 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 is compatible. 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. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- IceCoffee.Db4Net (>= 1.2.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
-
net10.0
- IceCoffee.Db4Net (>= 1.2.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
-
net8.0
- IceCoffee.Db4Net (>= 1.2.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
-
net9.0
- IceCoffee.Db4Net (>= 1.2.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.