LiteDB.Helper.IncludeAll 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LiteDB.Helper.IncludeAll --version 0.1.0
NuGet\Install-Package LiteDB.Helper.IncludeAll -Version 0.1.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="LiteDB.Helper.IncludeAll" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteDB.Helper.IncludeAll --version 0.1.0
#r "nuget: LiteDB.Helper.IncludeAll, 0.1.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 LiteDB.Helper.IncludeAll as a Cake Addin
#addin nuget:?package=LiteDB.Helper.IncludeAll&version=0.1.0

// Install LiteDB.Helper.IncludeAll as a Cake Tool
#tool nuget:?package=LiteDB.Helper.IncludeAll&version=0.1.0

.IncludeAll() Extension for LiteDB v5

Original author: Chiko
This extension class allows you to .IncludeAll subdocuments referenced in the registered entities in LiteDB v5.

Warning:

This package has not been heavily tested yet. Code may still needs to be polished. Issues and pull requests are welcome.

How to Use

Setting up

Add the package in the project.

dotnet add package LiteDB.Helper.IncludeAll

Import using.

using LiteDB.Helper.IncludeAll;
Register

Register the entities to get included on .IncludeAll() Define which entity shall dereference which subdocument, and with MemberExpression, point out what property should be dereferenced. For example:

LiteDBHelper.Register<Recipe, MaterialInRecipe>(r => r.Materials);

Provide its collection name if the subcollection is using custom collection name. For example:

LiteDBHelper.Register<Recipe, MaterialInRecipe>(r => r.Materials, "materials");

_Note: The Register statement creates the DbRef for you in the global BsonMapper.

Finally, IncludeAll()

The class LiteDBHelper defines an extension method for ILiteCollection<T>, so for any collection, you can, for example

var result = someCollection.IncludeAll().FindAll().ToList();
A short and quick example
using LiteDB;
using Types.TestTypes;

public class Test
{
    public void DoTest()
    {

        LiteDbHelper.Register<Recipe, MaterialInRecipe>(r => r.Materials);
        LiteDbHelper.Register<MaterialInRecipe, Material>(m => m.Material);
        LiteDbHelper.Register<Material, Cost>(m => m.Cost);

        var db = new LiteDatabase("test.db");

        Cost cost = new Cost
        {
            Amount = 20
        };
        var costs = db.GetCollection<Cost>("costs");
        cost.Id = costs.Insert(cost);

        Material material = new Material
        {
            Cost = cost,
            Name = "Mat 01"
        };
        var materials = db.GetCollection<Material>("materials");
        material.Id = materials.Insert(material);

        MaterialInRecipe mInRecipe = new MaterialInRecipe
        {
            Material = material,
            Weight = 500
        };
        var mInRecipes = db.GetCollection<MaterialInRecipe>("materialsInRecipe");
        mInRecipe.Id = mInRecipes.Insert(mInRecipe);

        Recipe recipe = new Recipe
        {
            Materials = new List<MaterialInRecipe> {
                mInRecipe
            },
            Name = "Recipe 01"
        };
        var recipes = db.GetCollection<Recipe>("recipes");
        recipes.Insert(recipe);

        var result = recipes.IncludeAll().FindAll().ToList();
    }
}
Some Tips

Inspect the database using LiteDB.Studio to make sure data stored as references.
Looking for Linux version? Hope this helps.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

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
0.1.0.3 1,412 10/25/2021
0.1.0.2 301 10/25/2021
0.1.0.1 315 10/25/2021
0.1.0 324 10/25/2021