EasyLiteDB 1.0.0

dotnet add package EasyLiteDB --version 1.0.0
NuGet\Install-Package EasyLiteDB -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyLiteDB" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyLiteDB --version 1.0.0
#r "nuget: EasyLiteDB, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasyLiteDB as a Cake Addin
#addin nuget:?package=EasyLiteDB&version=1.0.0

// Install EasyLiteDB as a Cake Tool
#tool nuget:?package=EasyLiteDB&version=1.0.0

Easy-LiteDB

Easy-LiteDB C# is a simple wrapper for LiteDB. Allow you to track changes and save changes to the database. It is designed to be easy to use and easy to understand. It is not designed to be the fastest or most efficient. User with enitity framework experience will find this library very easy to use.

Installation

Use the package manager to install Easy-LiteDB

dotnet add package LiteDB --version 5.0.15

Getting started

  1. Create a class that inherits from LiteDBEntity. This class will be used to represent the data in the database.
public class Person : LiteDBEntity
{
    public string Name { get; set; }
    public int Age { get; set; }
}
  1. Create a class that inherits from LiteDBContext. This class will be used to represent the database.
public class MyContext : LiteDBContext<Mycontext>
{
    public MyContext() : base("Filename=mycontext.db;Connection=shared"){}

    public LiteDBSet<Person> Peoples { get; private set; }
}
  1. Create an instance of the context and use it to access the database.
MyContext context = new MyContext();
var peoples = context.Peoples.ToList();

Basic Usage (Crud)

Create
MyContext context = new MyContext();

// Create
Person person = new Person { Name = "John", Age = 30 };
context.Peoples.Add(person);

// save changes
context.SaveChanges();
Read
MyContext context = new MyContext();

// Read
List<Person> peoples = context.Peoples.ToList();
Update
MyContext context = new MyContext();

// Update
Person person = context.Peoples.FirstOrDefault();
person.Name = "John Doe";
person.SetDirty();

// save changes
context.Peoples.SaveChanges();
Delete
// not implemented yet

Advanced Usage

Configuration

Use custom connection string for each DbSet. This is useful when you want to use different database file for each DbSet. default connection string will be used if not specified.

public class MyContext : LiteDBContext<Mycontext>
{
    public MyContext() : base("Filename=mycontext.db;Connection=shared"){}

    public LiteDBSet<Person> Peoples { get; private set; }

    protected override void Configure(IConfigureDbSet<ShopDbContext> configurer)
    {
        base.Configure(configurer);

        configurer.Configure(x => x.Peoples, x =>
        {
            x.UseCustomConnectionString("Filename=peoples.db;Connection=shared");
        });
    }
}
Query
MyContext context = new MyContext();

// Client side query (Linq)
List<Person> peoples = context.Peoples.Where(x => x.Age > 30)
.ToList();

// Server side query (LiteDb query)
List<Person> peoples = context.Peoples
    .UseQuery(query =>
    {
        query = query.Where(x => x._id != null);
    }).ToList()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 190 1/24/2023