sqlite-net

repository·master·Indexed 26 days ago

https://github.com/praeclarum/sqlite-net

A minimal, open-source library providing a lightweight ORM for .NET, .NET Core, and Mono applications to store data in SQLite 3 databases. It allows mapping classes to tables using attributes such as [PrimaryKey], [AutoIncrement], [Indexed], and [Ignore]. Available via the sqlite-net-pcl NuGet package or as single-file source implementations (SQLite.cs and SQLiteAsync.cs).

Tokens
387
Snippets
1
Records
3
Agent score
39%

What's inside sqlite-net

  1. Define data models with SQLite attributes

    master

    Use simple attributes to control how your classes are mapped to database tables:

    • [PrimaryKey]: Marks a property as the primary key.
    • [AutoIncrement]: Enables auto-incrementing for the primary key.
    • [Indexed]: Creates an index on the property.
    • [Ignore]: Tells the ORM to ignore this property during database operations.
    ```csharp
    public class Stock
    {
    	[PrimaryKey, AutoIncrement]
    	public int Id { get; set; }
    	public string Symbol { get; set; }
    }
    
    public class Valuation
    {
    	[PrimaryKey, AutoIncrement]
    	public int Id { get; set; }
    	[Indexed]
    	public int StockId { get; set; }
    	public DateTime Time { get; set; }
    	public decimal Price { get; set; }
    	[Ignore]
    	public string IgnoreField { get; set; }
    }
    ```埋