Embedded NoSQL Database--litedb

Source: Internet
Author: User

Litedb is a small, fast and lightweight NoSQL embedded database developed by open source. NET, Features:

Server-free NoSQL document storage with data stored in a single file
A simple API like MongoDb
100% C # code, support for. NET 3.5, single DLL, can be installed from NuGet: Install-package litedb
Supports ACID transaction control
Write failure recovery in log mode
can store POCO classes or bsondocument
Support for file storage and data flow storage (like Gridfs in MongoDB)
Single data file storage, similar to SQLite
Document Field index, for quick Search
Support for using LINQ queries
Shell command Line (get on-try this online version

Self-generated ID test
  /// <summary>        ///self-generated ID test/// </summary>         Public voidautoid_test () {//Open or create a new database            using(vardb =NewLitedatabase ("sample.db"))            {                varCs_int = db. Getcollection<entityint> ("int"); //int type self-generated ID                varCint_1 =Newentityint {Name ="Using Int 1" }; varCint_2 =Newentityint {Name ="Using Int 2" }; varCint_5 =Newentityint {Id =5, Name ="Using Int 5"};//set Id, do not generate (jump 3 and 4)!                varCint_6 =Newentityint {Id =0, Name ="Using Int 6"};//for int, 0 is empty                varcint_7 =Newentityint {Name ="Using Int 7" }; Cs_int.                Insert (cint_1); Cs_int.                Insert (cint_2); Cs_int.                Insert (cint_5); Cs_int.                Insert (Cint_6); Cs_int.                Insert (cint_7);                Console.WriteLine (cint_1.id);                Console.WriteLine (cint_2.id);                Console.WriteLine (cint_5.id);                Console.WriteLine (cint_6.id);                Console.WriteLine (cint_7.id); //GUID                varGUID =Guid.NewGuid (); varCguid_1 =NewEntityguid {Id = GUID, Name ="Using Guid" }; varCguid_2 =NewEntityguid {Name ="Using Guid 1" }; varCguid_3 =NewEntityguid {Name ="Using Guid 2" }; Console.WriteLine ("guid.newguid () ="+GUID);                Console.WriteLine (cguid_1.id);                Console.WriteLine (cguid_2.id);                Console.WriteLine (cguid_3.id); //OID                varOID =Objectid.newobjectid (); varCoid_1 =Newentityoid {Name ="ObjectId-1" }; varCoid_2 =Newentityoid {Id = oid, Name ="ObjectId-2" }; Console.WriteLine ("Objectid.newobjectid () ="+OID);                Console.WriteLine (coid_1.id);                Console.WriteLine (coid_2.id); //string does not have an auto-generated ID                varcstr_1 =Newentitystring {Name ="Object using String" };            Console.WriteLine (cstr_1.id); }        }
   /// <summary>    ///int type ID/// </summary>     Public classEntityint { Public intId {Get;Set; }  Public stringName {Get;Set; } }    /// <summary>    ///Guyid type ID/// </summary>     Public classEntityguid { PublicGuid Id {Get;Set; }  Public stringName {Get;Set; } }    /// <summary>    ///Litedb.objectid/// </summary>     Public classentityoid { PublicObjectId Id {Get;Set; }  Public stringName {Get;Set; } }    /// <summary>    ///String Type/// </summary>     Public classentitystring { Public stringId {Get;Set; }  Public stringName {Get;Set; } }

As shown in the following:

The int type ID automatically grows, and when you set the ID greater than 0 (5), it skips 3, 4, and the subsequent growth starts from 5.

The ID of the GUID type requires our own build.

The OID type ID is also required to build itself.

The string type cannot automatically generate an ID.

For other functions:

Large files, concurrency, JSON, LINQ, Filestorage and other functions, you can refer to the source code inside the unit test, as follows:

Embedded NoSQL Database--litedb

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.