SQLite Wrapper

Class Library
C#
GitHub Repository

What It Is

A handy way to work with SQLite from C#; simplies a lot of things.

Status

Last Reviewed:

I’ve used this quite a bit in the past, though I’m not sure I have this running anywhere right now.

Details

This is not an ORM, because we have Entity Framework for that. This library just lets you do some really easy things with SQLite. I wrote it because I got tired of writing the same code over and over.

This might have been a dumb idea. It’s a handy little wrapper to make working with SQLite easier, but this may already be handled by Dapper (which I love; no idea why I didn’t think of it).

Lots more doc at the repo link above, but some basic use cases are below.

var db = new Database(@"C:\friends.db"); 

db.AddTable(new Table("friends",
  new TextColumn("first_name", "NOT NULL"),
  new TextColumn("last_name", "NOT NULL"),
  new NumberColumn("age")
));

db["friends"].AddRecord(new {
  first_name = "Monica",
  last_name = "Gellar",
  age = 28}
);

var myFriendsDataReader = db.Query("SELECT * FROM friends");

var numberOfOldFriends = db.GetValue<int>("SELECT count(*) FROM friends WHERE age = 30");

db.Execute("UPDATE friends SET last_name = @last_name WHERE first_name = @first_name", new { 
    last_name = "the Divorce Force",
    first_name = "Ross"
});