Posts LiteDB - Embedded NoSQL database for .NET
Post
Cancel

LiteDB - Embedded NoSQL database for .NET

An open source MongoDB-like database with zero configuration - mobile ready.

http://www.litedb.org/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Basic example
public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string[] Phones { get; set; }
    public bool IsActive { get; set; }
}

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

    // Create your new customer instance
    var customer = new Customer
    { 
        Name = "John Doe", 
        Phones = new string[] { "8000-0000", "9000-0000" }, 
        IsActive = true
    };

    // Insert new customer document (Id will be auto-incremented)
    customers.Insert(customer);

    // Update a document inside a collection
    customer.Name = "Joana Doe";

    customers.Update(customer);

    // Index document using a document property
    customers.EnsureIndex(x => x.Name);

    // Use Linq to query documents
    var results = customers.Find(x => x.Name.StartsWith("Jo"));
}

LiteDB.dll v5.0alpha2 - 2018 - 428kb requires framework 4.5 v0.5 - 2014 - 96kb requires framework 3.5

https://www.nuget.org/packages/LiteDB/0.5.0

origin - https://www.pipiscrew.com/?p=15419 litedb-embedded-nosql-database-for-net

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags