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 (5)
Showing the top 5 NuGet packages that depend on LiteDB.Queryable:
Package | Downloads |
---|---|
Fluxera.Repository.LiteDB
A LiteDB repository implementation. |
|
TestTestCMS.Repositories.LiteDb
Repositories LiteDB. |
|
Magicube.Data.LiteDb
Package Description |
|
GoLive.Saturn.Data.LiteDb
An experimental Rapid Prototype Development Framework in c#/.net core. |
|
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)
|
Version | Downloads | Last updated | |
---|---|---|---|
9.0.0 | 613 | 11/14/2024 | |
2.3.3 | 394 | 11/1/2024 | |
2.3.2 | 805 | 7/9/2024 | |
2.3.1 | 669 | 6/8/2024 | |
2.3.0 | 909 | 3/20/2024 | |
2.2.2 | 137 | 3/19/2024 | |
2.2.1 | 174 | 3/6/2024 | |
2.2.0 | 341 | 2/18/2024 | |
2.1.0 | 1,965 | 11/24/2023 | |
2.0.0 | 326 | 11/16/2023 | |
1.0.8 | 168 | 11/12/2023 | |
1.0.7 | 1,022 | 7/23/2023 | |
1.0.6 | 1,163 | 3/22/2023 | |
1.0.5 | 279 | 3/16/2023 | |
1.0.4 | 404 | 2/24/2023 | |
1.0.3 | 484 | 1/18/2023 | |
1.0.2 | 649 | 12/12/2022 | |
1.0.1 | 445 | 12/3/2022 | |
1.0.0 | 339 | 12/2/2022 |