VOOZH about

URL: https://www.nuget.org/packages/LiteDB.Queryable/

⇱ NuGet Gallery | LiteDB.Queryable 10.0.2




👁 Image
LiteDB.Queryable 10.0.2

dotnet add package LiteDB.Queryable --version 10.0.2
 
 
NuGet\Install-Package LiteDB.Queryable -Version 10.0.2
 
 
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="10.0.2" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteDB.Queryable" Version="10.0.2" />
 
Directory.Packages.props
<PackageReference Include="LiteDB.Queryable" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LiteDB.Queryable --version 10.0.2
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LiteDB.Queryable, 10.0.2"
 
 
#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.
#:package LiteDB.Queryable@10.0.2
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LiteDB.Queryable&version=10.0.2
 
Install as a Cake Addin
#tool nuget:?package=LiteDB.Queryable&version=10.0.2
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 netstandard2.1 is compatible. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
TestTestCMS.Repositories.LiteDb

Repositories LiteDB.

Magicube.Data.LiteDb

Package Description

FluentCMS.Repositories.LiteDb

Repositories LiteDB.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on LiteDB.Queryable:

Repository Stars
fluentcms/FluentCMS
ASP.NET Core Blazor Content Management System (CMS)