LiteDB.Queryable 2.3.0

dotnet add package LiteDB.Queryable --version 2.3.0
NuGet\Install-Package LiteDB.Queryable -Version 2.3.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.Queryable" Version="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteDB.Queryable --version 2.3.0
#r "nuget: LiteDB.Queryable, 2.3.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.Queryable as a Cake Addin
#addin nuget:?package=LiteDB.Queryable&version=2.3.0

// Install LiteDB.Queryable as a Cake Tool
#tool nuget:?package=LiteDB.Queryable&version=2.3.0

LiteDB.Queryable

An IQueryable wrapper implementation for LiteDB with additional async extensions.

This library allows the use of LINQ extensions methods for querying LiteDB.

The LiteQueryable<T> implementation is a warpper around a ILiteCollection<T> or a ILiteCollectionAsync<>. The LINQ extenions call are delegated to the equivalent methods of the LiteDB API.

Usage

Add the NuGet package to your project: LiteDB.Queryable

You can then aquire an IQueryable<T> instance using one of the available AsQueryable extension methods for ILiteCollection<T> or ILiteCollectionAsync<T>. The async variant is provided by the litedb-async project.

LiteDatabase database = new LiteDatabase("test.db");
ILiteCollection<Person> collection = database.GetCollection<Person>("people");
IQueryable<Person> queryable = collection.AsQueryable();

or

LiteDatabaseAsync database = new LiteDatabaseAsync("test.db");
ILiteCollectionAsync<Person> collection = database.GetCollection<Person>("people");
IQueryable<Person> queryable = collection.AsQueryable();

After that you can use the synchronous LINQ extensions with both variants and the asynchronous ones with the second variant.

Supported LINQ extensions

You can use the following methods to configure your query. Those methods are available in both variants.

  • Where
  • OrderBy
  • OrderByDescending
  • Skip
  • Take
  • Include
  • Select

The ThenBy/ThenByDescending methods and multiple OrderBy/OrderByDescending class are not supported at the moment, because LiteDB doesn't support multiple order exprssions.

Synchronous extenions

  • ToList
  • ToArray
  • ToDictionary
  • First
  • FirstOrDefault
  • Single
  • SingleOrDefault
  • Count
  • LongCount
  • Any
  • Sum
  • Average
  • Min
  • Max

Asynchronous extenions

  • ToListAsync
  • ToArrayAsync
  • ToDictionaryAsync
  • FirstAsync
  • FirstOrDefaultAsync
  • SingleAsync
  • SingleOrDefaultAsync
  • CountAsync
  • LongCountAsync
  • AnyAsync
  • SumAsync
  • AverageAsync
  • MinAsync
  • MaxAsync

Example

LiteDatabase database = new LiteDatabase("test.db");
ILiteCollection<Person> collection = database.GetCollection<Person>("people");
IQueryable<Person> queryable = collection.AsQueryable();

IList<Person> result = queryable
	.Where(x => x.Name.StartsWith("T"))
	.OrderBy(x => x.Age)
	.ToList();

Person result = queryable
	.Where(x => x.Age > 35)
	.FirstOrDefault();

string result = queryable
	.Where(x => x.Age > 35)
	.Select(x => x.Name)
	.FirstOrDefault();

or

LiteDatabaseAsync database = new LiteDatabaseAsync("test.db");
ILiteCollectionAsync<Person> collection = database.GetCollection<Person>("people");
IQueryable<Person> queryable = collection.AsQueryable();

IList<Person> result = await queryable
	.Where(x => x.Name.StartsWith("T"))
	.OrderBy(x => x.Age)
	.ToListAsync();

Person result = await queryable
	.Where(x => x.Age > 35)
	.FirstOrDefaultAsync();

string result = await queryable
	.Where(x => x.Age > 35)
	.Select(x => x.Name)
	.FirstOrDefaultAsync();

References

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 is compatible.  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 is compatible.  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 is compatible. 
.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.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on LiteDB.Queryable:

Package Downloads
Fluxera.Repository.LiteDB The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A LiteDB repository implementation.

Magicube.Data.LiteDb

Package Description

GoLive.Saturn.Data.LiteDb

An experimental Rapid Prototype Development Framework in c#/.net core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.3.0 422 3/20/2024
2.2.2 97 3/19/2024
2.2.1 132 3/6/2024
2.2.0 239 2/18/2024
2.1.0 1,506 11/24/2023
2.0.0 246 11/16/2023
1.0.8 112 11/12/2023
1.0.7 947 7/23/2023
1.0.6 744 3/22/2023
1.0.5 234 3/16/2023
1.0.4 325 2/24/2023
1.0.3 420 1/18/2023
1.0.2 557 12/12/2022
1.0.1 384 12/3/2022
1.0.0 299 12/2/2022