https://github.com/zzzprojects/linq-async
C# LINQ Async extension methods library for async/await task.
https://github.com/zzzprojects/linq-async
async linq-async-extensions linq-methods
Last synced: 8 months ago
JSON representation
C# LINQ Async extension methods library for async/await task.
- Host: GitHub
- URL: https://github.com/zzzprojects/linq-async
- Owner: zzzprojects
- License: mit
- Created: 2015-12-19T20:43:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-06-01T15:20:23.000Z (about 1 year ago)
- Last Synced: 2025-09-12T00:03:28.651Z (9 months ago)
- Topics: async, linq-async-extensions, linq-methods
- Language: C#
- Homepage: https://zzzprojects.com
- Size: 164 KB
- Stars: 101
- Watchers: 6
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# What's LINQ-Async?
LINQ-Async allows you to **chain async task and orders async predicate with fluent API**.
## Features
- LINQ Async Extensions
- LINQ Async Precicate Extensions
- OrderByPredicateCompletion
- StartPredicateConcurrently
- LINQ Async Task Extensions
- LINQ Async Enumerable Task Extensions
- OrderByCompletion
- SelectResult
## Sponsors
ZZZ Projects owns and maintains **LINQ-Async** as part of our [mission](https://zzzprojects.com/mission) to add value to the .NET community
Through [Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=zzzprojects&utm_medium=linq-async) and [Dapper Plus](https://dapper-plus.net/?utm_source=zzzprojects&utm_medium=linq-async), we actively sponsor and help key open-source libraries grow.
[](https://entityframework-extensions.net/bulk-insert?utm_source=zzzprojects&utm_medium=linq-async)
[](https://dapper-plus.net/bulk-insert?utm_source=zzzprojects&utm_medium=linq-async)
## Download
[](https://www.nuget.org/packages/Z.Linq.Async)
[](https://www.nuget.org/packages/Z.Linq.Async)
```
PM> NuGet\Install-Package Z.EntityFramework.Plus.EFCore
```
```
> dotnet add package Z.EntityFramework.Plus.EFCore
```
## LINQ Async Extensions
##### Problem
You want to use LINQ methods asynchronously.
##### Solution
All LINQ extension methods and overloads are supported. You can easily create any asynchronous task.
```chsarp
// Using Z.Linq
public Task> MyAsyncMethod(CancellationToken cancellationToken)
{
List customers = DB.GetCustomers();
var task = list.WhereAsync(c => /* long predicate */, cancellationToken);
// ... synchronous code ...
return task;
}
```
## LINQ Async Predicate Extensions
##### Problem
You want to resolve a predicate asynchronously and start all predicates concurrently and/or order them by completion.
##### Solution
All LINQ extension methods and overloads using a predicate are supported. You can easily use an asynchronously predicate and choose how the predicate will be resolved:
- OrderByPredicateCompletion(bool)
- StatePredicateConcurrently(bool)
**Support:**
- Deferred
- SkipWhile
- Where
- Immediate
- All
- Any
- Count
- First
- FirstOrDefault
- LongCount
- Single
- SingleOrDefault
```chsarp
// Using Z.Linq
// Change global default value
LinqAsyncManager.DefautlValue.OrderByPredicateCompletion = false;
LinqAsyncManager.DefaultValue.StartPredicateConcurrently = false;
public Task> MyAsyncTaskMethod(CancellationToken cancellationToken)
{
List customers = DB.GetCustomers();
// GET all customers by predicate completion
var task = list.WhereAsync(c => MyAsyncPredicate(DB.IsCustomerActiveAsync(c)))
.OrderByPredicateCompletion();
// ... synchronous code ...
return task;
}
```
**[Learn more](https://github.com/zzzprojects/LINQ-AsyncExtensions/wiki/LINQ-AsyncPredicateExtensions)**
## LINQ Async Task Extensions
##### Problem
You want to chain LINQ methods with Task<IEnumerable<T>>.
##### Solution
All LINQ extensions methods and overloads are supported. You can easily chain multiples LINQ methods before awaiting your final task.
**Support:**
- Array
- Enumerable
- List
_Other types must use "AsEnumerable()" method to allow to chain LINQ methods._
```chsarp
// Using Z.Linq
public async Task> MyAsyncTaskMethod(CancellationToken cancellationToken)
{
// GET the five first customers which the predicate has completed
var task = list.WhereAsync(c => MyAsyncPredicate(DB.IsCustomerActiveAsync(c)))
.OrderByPredicateCompletion()
.Take(5)
.ToList();
// ... synchronous code ...
return task;
}
```
**[Learn more](https://github.com/zzzprojects/LINQ-AsyncExtensions/wiki/LINQ-AsyncTaskExtensions)**
## LINQ Async Enumerable Task Extensions
##### Problem
You want to use LINQ methods with enumerable tasks and order them by completion.
##### Solution
**Support:**
- OrderByCompletion
- SelectResult
```chsarp
// Using Z.Linq
public async Task> MyAsyncTaskMethod(CancellationToken cancellationToken)
{
// GET customer from concurrent web service
IEnumerable>> task = WebService.GetCustomers();
// GET the customer list from the first web service completed
var taskFirstCompleted = task.SelectResultByCompletion()
.SelectResult()
.First()
// GET the five first customers which the predicate has completed
var task = taskFirstCompleted.WhereAsync(c => MyAsyncPredicate(DB.IsCustomerActiveAsync(c)))
.OrderByPredicateCompletion()
.Take(5)
.ToList();
// ... synchronous code ...
return task;
}
```
**[Learn more](https://github.com/zzzprojects/LINQ-AsyncExtensions/wiki/LINQ-AsyncEnumerableExtensions)**
## More Projects
- Projects:
- [EntityFramework Extensions](https://entityframework-extensions.net/)
- [Dapper Plus](https://dapper-plus.net/)
- [C# Eval Expression](https://eval-expression.net/)
- Learn Websites
- [Learn EF Core](https://www.learnentityframeworkcore.com/)
- [Learn Dapper](https://www.learndapper.com/)
- Online Tools:
- [.NET Fiddle](https://dotnetfiddle.net/)
- [SQL Fiddle](https://sqlfiddle.com/)
- [ZZZ Code AI](https://zzzcode.ai/)
- and much more!
To view all our free and paid projects, visit our website [ZZZ Projects](https://zzzprojects.com/).