Linger.DataAccess.Sqlite 0.8.1-preview

This is a prerelease version of Linger.DataAccess.Sqlite.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Linger.DataAccess.Sqlite --version 0.8.1-preview
                    
NuGet\Install-Package Linger.DataAccess.Sqlite -Version 0.8.1-preview
                    
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="Linger.DataAccess.Sqlite" Version="0.8.1-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linger.DataAccess.Sqlite" Version="0.8.1-preview" />
                    
Directory.Packages.props
<PackageReference Include="Linger.DataAccess.Sqlite" />
                    
Project file
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 Linger.DataAccess.Sqlite --version 0.8.1-preview
                    
#r "nuget: Linger.DataAccess.Sqlite, 0.8.1-preview"
                    
#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 Linger.DataAccess.Sqlite@0.8.1-preview
                    
#: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=Linger.DataAccess.Sqlite&version=0.8.1-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Linger.DataAccess.Sqlite&version=0.8.1-preview&prerelease
                    
Install as a Cake Tool

Linger.DataAccess.Sqlite

δΈ­ζ–‡ | English

Overview

Linger.DataAccess.Sqlite is a comprehensive SQLite database access library that leverages SQLite-specific features while providing secure, high-performance database operations. It offers factory methods, advanced SQLite capabilities, and full async support for modern .NET applications.

Features

  • 🏭 Factory Methods: Easy creation of in-memory, file-based, and temporary databases
  • πŸ”’ Security First: All queries use parameterized statements to prevent SQL injection
  • ⚑ SQLite Optimizations: SQLite-specific features
  • πŸ”„ Async Support: Full async/await support with CancellationToken
  • 🎯 Multi-Framework: Supports .NET 9.0, .NET 8.0, and .NET Framework 4.6.2
  • πŸ“Š Database Management: Backup, restore, table operations, and schema management

Quick Start

using Linger.DataAccess.Sqlite;

// Create file database
var fileDb = SqliteHelper.CreateFileDatabase("myapp.db");

// Secure parameterized queries
var users = fileDb.Query("SELECT * FROM users WHERE age > @age", 
    new SQLiteParameter("@age", 18));

// Batch processing with automatic pagination
var userIds = new List<string> { "1", "2", "3", ..., "5000" };
var results = fileDb.Page("SELECT * FROM users WHERE id IN ({0})", userIds);

// SQLite-specific operations
await fileDb.VacuumDatabaseAsync();
await fileDb.AnalyzeDatabaseAsync();

Factory Methods

Database Creation

// File-based database (persistent)
var fileDb = SqliteHelper.CreateFileDatabase("app.db", createIfNotExists: true);

Core Methods

Batch Operations

  • Page(sql, parameters) - Intelligent batch processing for large parameter lists
  • PageAsync(sql, parameters, cancellationToken) - Async batch processing

Existence Checks

  • Exists(sql, parameters) - Parameterized existence verification
  • ExistsAsync(sql, parameters, cancellationToken) - Async existence checks

Query Operations

  • Query(sql, parameters) - Parameterized query returning DataSet
  • QueryAsync(sql, parameters, cancellationToken) - Async query returning DataSet

SQLite-Specific Features

Performance Optimizations

// Optimize database performance
await sqlite.VacuumDatabaseAsync();   // Reclaim space and defragment
await sqlite.AnalyzeDatabaseAsync();  // Update query planner statistics

// Get database size
var size = await sqlite.GetDatabaseSizeAsync();

Database Management

// Backup database
await sqlite.BackupDatabaseAsync("backup.db");

// Table operations
var tables = await sqlite.GetTableNamesAsync();
bool exists = await sqlite.TableExistsAsync("users");

// Integrity check
var integrityResult = await sqlite.CheckIntegrityAsync();

Transaction Support

// Automatic transaction management
await sqlite.ExecuteInTransactionAsync(new[]
{
    "INSERT INTO users (name) VALUES ('John')",
    "INSERT INTO logs (action) VALUES ('User created')"
});

Security Features

SQL Injection Prevention

// ❌ Vulnerable (old approach)
var sql = $"SELECT * FROM users WHERE name = '{userName}'";

// βœ… Secure (parameterized)
var sql = "SELECT * FROM users WHERE name = @userName";
var result = sqlite.Query(sql, new SQLiteParameter("@userName", userName));

Performance Best Practices

Connection Pooling

// Use connection pooling for file databases
var connectionString = "Data Source=app.db;Pooling=true;Max Pool Size=100;";
var sqlite = new SqliteHelper(connectionString);

Batch Insertions

// Efficient batch insertions
var users = GenerateTestUsers(10000);
await sqlite.ExecuteInTransactionAsync(users.Select(user => 
    $"INSERT INTO users (name, email) VALUES ('{user.Name}', '{user.Email}')"));

Advanced Features

Database Management

// Get database size
var size = await sqlite.GetDatabaseSizeAsync();

// Check database integrity
var integrityResult = await sqlite.CheckIntegrityAsync();

// Get all table names
var tableNames = await sqlite.GetTableNamesAsync();
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.  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 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. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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.9.1-preview 31 9/16/2025
0.9.0-preview 62 9/12/2025
0.8.5-preview 137 8/31/2025
0.8.4-preview 256 8/25/2025
0.8.3-preview 116 8/20/2025
0.8.2-preview 149 8/4/2025
0.8.1-preview 94 7/30/2025
0.1.2-alpha 83 12/17/2024
0.1.1-alpha 76 12/17/2024
0.1.0-alpha 76 12/6/2024
0.0.2-alpha 69 10/3/2024