Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 749 Bytes

README.md

File metadata and controls

41 lines (33 loc) · 749 Bytes

JFA.Database.Sqlite

Simple object mapping tool for Sqlite

Steps

Install package

NuGet\Install-Package JFA.Database.Sqlite -Version <VERSION>

Create DbContext

using JFA.Database.Sqlite;

internal class AppDbContext : DbContext
{
    public AppDbContext(string connectionString) : base(connectionString)
    {
        Users = Configure<User>();
    }

    public DbSet<User> Users { get; set; }
}

Insert data and read

var dbContext = new AppDbContext("Data Source = users.db");

// add new rows
dbContext.Insert(new User { Name = "Csharp", Phone = "123456789" });

// read
var _user = dbContext.Users.First(u => u.Id == 1);

// update
_user.Name = "DotNet";
_user.Phone = "987654321";
dbContext.Save();