LiteDB: Embedded .NET NoSQL Database » Developer.Team

LiteDB: Embedded .NET NoSQL Database

LiteDB: Embedded .NET NoSQL Database
LiteDB: Embedded .NET NoSQL Database


LiteDB is serverless database delivered in a single DLL (less than 350kb) fully written in .NET C# managed code (compatible with .NET 3.5, 4.x, NETStandard 1.3 and 2.0). Install via NuGet or just copy DLL to your bin project folder.

Fast and lightweight

LiteDB is a simple and fast NoSQL database solution. Ideal for:

Mobile Apps
Desktop/local small applications
Application file format
Small web applications
One database per account/user data store

And much more...

Portable UWP and Xamarin iOS/Android
ACID transaction
Single datafile (like SQLite)
Recovery data in writing failure (journal mode)
Map your POCO class to BsonDocument
Fluent API for custom mapping
Cross collections references (DbRef)
Store files and stream data (like GridFS in MongoDB)
LINQ support
FREE for everyone - including commercial use

// Create your POCO class
public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
    public string[] Phones { get; set; }
    public bool IsActive { get; set; }
}

// Open database (or create if doesn't exist)
using(var db = new LiteDatabase(@"MyData.db"))
{
    // Get customer collection
    var col = db.GetCollection<Customer>("customers");

    // Create your new customer instance
	var customer = new Customer
    { 
        Name = "John Doe", 
        Phones = new string[] { "8000-0000", "9000-0000" }, 
        Age = 39,
        IsActive = true
    };
    
    // Create unique index in Name field
    col.EnsureIndex(x => x.Name, true);
	
    // Insert new customer document (Id will be auto-incremented)
    col.Insert(customer);
	
    // Update a document inside a collection
    customer.Name = "Joana Doe";
	
    col.Update(customer);
	
    // Use LINQ to query documents (with no index)
    var results = col.Find(x => x.Age > 20);
}