SqLiteGenericRepository 1.0.8

dotnet add package SqLiteGenericRepository --version 1.0.8
NuGet\Install-Package SqLiteGenericRepository -Version 1.0.8
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="SqLiteGenericRepository" Version="1.0.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SqLiteGenericRepository --version 1.0.8
#r "nuget: SqLiteGenericRepository, 1.0.8"
#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 SqLiteGenericRepository as a Cake Addin
#addin nuget:?package=SqLiteGenericRepository&version=1.0.8

// Install SqLiteGenericRepository as a Cake Tool
#tool nuget:?package=SqLiteGenericRepository&version=1.0.8

SqliteRepository

Straightforward CRUD repository for Sqlite

The main purpose of SqliteRepository is to provide an as easy as possible DAL for services using Sqlite without tinkering.

How to use it

Add your connection string to appsettings.json

{
  "SQLiteDbOptions": {
    "DatabaseFilename": "YourDatabaseName.db3",
    "DatabaseLocation": "C:/your/database/directory"
  }
}

Then add an entity which implements IEntity<int> which basically means it has an ID field with PrimaryKey and AutoIncrement attributes.

    public class WeatherForecast : IEntity<int>
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }

        //...
    }

For each entity you need a repository which implements IReadWriteRepository<TEntity, int>. It is possible to add your own methods to the repository and of course to override the default ones.

    public interface IWeatherForecastRepository : IReadWriteRepository<WeatherForecast, int>
    {
      Task<IList<WeatherForecast>> GetAllWeatherForecastsWith16Degree();
    }
    public class WeatherForecastSqliteRepository : ReadWriteRepository<WeatherForecast, int>, IWeatherForecastRepository
    {
        public WeatherForecastSqliteRepository(IOptions<SQLiteDbOptions> sqlLiteOptions) : base(sqlLiteOptions)
        {

        }
        
        public async Task<IList<WeatherForecast>> GetAllWeatherForecastsWith16Degree()
        {
            return await Table
              .Where(x=> x.TemperatureC == 16)
              .ToListAsync();
        }
    }

Last thing to do is to inject your connectionstring and the repository

  services.Configure<SQLiteDbOptions>(Configuration.GetSection("SQLiteDbOptions"));
  services.AddScoped<IWeatherForecastRepository, WeatherForecastRepository>();
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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
1.0.8 121 8/31/2023
1.0.7 129 8/30/2023
1.0.6 128 8/29/2023
1.0.5 115 8/25/2023
1.0.4 122 8/24/2023
1.0.3 101 8/24/2023
1.0.2 113 8/24/2023
1.0.1 109 8/22/2023
1.0.0 106 8/22/2023

added null/empty catch on AddRange