Generic.Sqlite.Repository
1.0.6
dotnet add package Generic.Sqlite.Repository --version 1.0.6
NuGet\Install-Package Generic.Sqlite.Repository -Version 1.0.6
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="Generic.Sqlite.Repository" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Generic.Sqlite.Repository" Version="1.0.6" />
<PackageReference Include="Generic.Sqlite.Repository" />
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 Generic.Sqlite.Repository --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Generic.Sqlite.Repository, 1.0.6"
#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 Generic.Sqlite.Repository@1.0.6
#: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=Generic.Sqlite.Repository&version=1.0.6
#tool nuget:?package=Generic.Sqlite.Repository&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Genric.Sqlite.Repository
Genric.Sqlite.Repository is a simple library designed to facilitate SQLite usage in small projects, automatically creating the database and tables as needed. The library provides a generic base repository, allowing extension with custom methods.
Features
- Automatically creates the database file if it does not exist.
- Automatically creates tables defined by entities annotated with
[Table("TableName")]. - Includes a resilience mechanism for SQLite connections.
- Provides a base repository with standard methods such as
Add. - Allows extension for creating custom methods.
Installation
Add the library to your project:
# Example of installation via .NET CLI
dotnet add package Genric.Sqlite.Repository
Usage
1. Configure the connection in appsettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=app.db"
}
}
2. Create an entity
using System.ComponentModel.DataAnnotations.Schema;
[Table("User")]
public class User
{
public int Id { get; set; }
public string Name { get; set; }
}
3. Create a repository
public class UserRepository : BaseRepository<User>
{
public UserRepository(IConfiguration configuration, ResiliencePipelineProvider<string> pipelineProvider)
: base(configuration, pipelineProvider)
{
}
}
4. Register in Dependency Injection (DI)
builder.Services.AddSingleton<ResiliencePipelineProvider<string>>();
builder.Services.AddScoped<UserRepository>();
5. Use the repository
var userRepository = serviceProvider.GetRequiredService<UserRepository>();
await userRepository.Add(new User { Name = "John" });
Contribution
Contributions are welcome! To suggest improvements, open a pull request or an issue.
License
This project is licensed under the MIT License.
| 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 was computed. 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.
-
net8.0
- Dapper (>= 2.1.35)
- Dapper.Contrib (>= 2.0.78)
- Microsoft.Data.Sqlite (>= 9.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Polly.Core (>= 8.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.