LiteDB.Queryable
9.0.0
dotnet add package LiteDB.Queryable --version 9.0.0
NuGet\Install-Package LiteDB.Queryable -Version 9.0.0
<PackageReference Include="LiteDB.Queryable" Version="9.0.0" />
paket add LiteDB.Queryable --version 9.0.0
#r "nuget: LiteDB.Queryable, 9.0.0"
// Install LiteDB.Queryable as a Cake Addin #addin nuget:?package=LiteDB.Queryable&version=9.0.0 // Install LiteDB.Queryable as a Cake Tool #tool nuget:?package=LiteDB.Queryable&version=9.0.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 | Versions 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. net9.0 is compatible. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- LiteDB (>= 5.0.21)
- LiteDB.Async (>= 0.1.8)
- System.Linq.Async (>= 6.0.1)
-
net6.0
- LiteDB (>= 5.0.21)
- LiteDB.Async (>= 0.1.8)
- System.Linq.Async (>= 6.0.1)
-
net7.0
- LiteDB (>= 5.0.21)
- LiteDB.Async (>= 0.1.8)
- System.Linq.Async (>= 6.0.1)
-
net8.0
- LiteDB (>= 5.0.21)
- LiteDB.Async (>= 0.1.8)
- System.Linq.Async (>= 6.0.1)
-
net9.0
- LiteDB (>= 5.0.21)
- LiteDB.Async (>= 0.1.8)
- System.Linq.Async (>= 6.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on LiteDB.Queryable:
Package | Downloads |
---|---|
Fluxera.Repository.LiteDB
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 (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)
|
Version | Downloads | Last updated | |
---|---|---|---|
9.0.0 | 197 | 11/14/2024 | |
2.3.3 | 225 | 11/1/2024 | |
2.3.2 | 721 | 7/9/2024 | |
2.3.1 | 658 | 6/8/2024 | |
2.3.0 | 903 | 3/20/2024 | |
2.2.2 | 131 | 3/19/2024 | |
2.2.1 | 168 | 3/6/2024 | |
2.2.0 | 335 | 2/18/2024 | |
2.1.0 | 1,926 | 11/24/2023 | |
2.0.0 | 316 | 11/16/2023 | |
1.0.8 | 161 | 11/12/2023 | |
1.0.7 | 1,015 | 7/23/2023 | |
1.0.6 | 1,059 | 3/22/2023 | |
1.0.5 | 275 | 3/16/2023 | |
1.0.4 | 396 | 2/24/2023 | |
1.0.3 | 478 | 1/18/2023 | |
1.0.2 | 645 | 12/12/2022 | |
1.0.1 | 441 | 12/3/2022 | |
1.0.0 | 335 | 12/2/2022 |