• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C# LINQ Async extension methods library for async/await task.

Library Powered By

This library is powered by Entity Framework Extensions

Entity Framework Extensions

What's LINQ-Async?

LINQ-Async allows you to chain async task and orders async predicate with fluent API.

Features

Download

download

PM> Install-Package Z.Linq.Async

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.

// Using Z.Linq

public Task<IEnumerable<Customer>> MyAsyncMethod(CancellationToken cancellationToken)
{
    List<Customer> 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
// Using Z.Linq

// Change global default value
LinqAsyncManager.DefautlValue.OrderByPredicateCompletion = false;
LinqAsyncManager.DefaultValue.StartPredicateConcurrently = false;

public Task<IEnumerable<Customer>> MyAsyncTaskMethod(CancellationToken cancellationToken)
{
    List<Customer> 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

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.

// Using Z.Linq

public async Task<List<Customer>> 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

LINQ Async Enumerable Task Extensions

Problem

You want to use LINQ methods with enumerable tasks and order them by completion.

Solution

Support:

  • OrderByCompletion
  • SelectResult
// Using Z.Linq

public async Task<List<Customer>> MyAsyncTaskMethod(CancellationToken cancellationToken)
{
    // GET customer from concurrent web service
    IEnumerable<Task<List<Customer>>> 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

Contribute

The best way to contribute is by spreading the word about the library:

  • Blog it
  • Comment it
  • Star it
  • Share it

A HUGE THANKS for your help.

More Projects

To view all our free and paid projects, visit our website ZZZ Projects.

More Repositories

1

html-agility-pack

Html Agility Pack (HAP) is a free and open-source HTML parser written in C# to read/write DOM and supports plain XPATH or XSLT. It is a .NET code library that allows you to parse "out of the web" HTML files.
C#
2,635
star
2

EntityFramework-Plus

Entity Framework Plus extends your DbContext with must-haves features: Include Filter, Auditing, Caching, Query Future, Batch Delete, Batch Update, and more
C#
2,251
star
3

Z.ExtensionMethods

C# Extension Methods | Over 1000 extension methods:
C#
1,574
star
4

System.Linq.Dynamic.Core

The .NET Standard / .NET Core version from the System Linq Dynamic functionality.
C#
1,555
star
5

EntityFramework.Extended

Add-on feature for Entity Framework
C#
1,339
star
6

EntityFramework.DynamicFilters

Global filtering for Entity Framework.
C#
501
star
7

Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
C#
452
star
8

EntityFramework-Effort

Entity Framework Effort is a powerful tool that enables a convenient way to create automated tests for Entity Framework based applications.
C#
431
star
9

System.Linq.Dynamic

[Deprecated] This is the Microsoft assembly for the .Net 4.0 Dynamic language functionality.
425
star
10

Dapper-Plus

Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
C#
384
star
11

EntityFramework-Extensions

Entity Framework Bulk Operations | Improve Entity Framework performance with Bulk SaveChanges, Insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL and SQLite.
C#
344
star
12

GraphDiff

GraphDiff is a library that allows the automatic update of a detached graph using Entity Framework code first.
C#
333
star
13

sqlfiddle3

New version based on vert.x and docker
JavaScript
331
star
14

sqlfiddle

JavaScript
275
star
15

findandreplace

fnr.exe - Find and Replace (FNR) is an open source tool to find and replace text in multiple files. It can quickly search through large numbers of files and also find the information using regular expressions specifying the form of what you want, instead of literal text.
C#
243
star
16

nmemory

NMemory is a lightweight non-persistent in-memory relational database engine that is purely written in C# and can be hosted by .NET applications.
C#
232
star
17

sqlfiddle2

New version of SQL Fiddle based on OpenIDM
JavaScript
195
star
18

Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
C#
142
star
19

zzzcode.ai

AI Website for developers. Use ChatGPT to answer questions, write code, and more.
108
star
20

EntityFramework-Classic

Entity Framework Classic is a supported version of the latest EF6 codebase. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.
C#
102
star
21

Eval-SQL.NET

SQL Eval Function | Dynamically Evaluate Expression in SQL Server using C# Syntax.
C#
95
star
22

EntityFrameworkExtras

EntityFrameworkExtras provides some useful additions to EntityFramework such as executing Stored Procedures with User-Defined Table Types and Output Parameters.
C#
80
star
23

awesome-entity-framework-core

Awesome EF Core third party-libraries, documentation, and tutorials!
57
star
24

Dapper.Transaction

IDbTransaction extension methods for Dapper: A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..
C#
29
star
25

awesome-dapper

Awesome Dapper third party-libraries, documentation, and tutorials!
16
star
26

EntityFramework6-DotNetStandard

The support has been moved here: https://github.com/zzzprojects/EntityFramework-Classic
C#
13
star
27

awesome-entity-framework-6

Awesome EF6 third party-libraries, documentation, and tutorials!
12
star
28

Compiler-Expression.NET

C# Code Compiler | Code Analysis and Code Compiler for Eval-Expression.NET and Eval-SQL.NET
12
star
29

awesome-csharp-expression-evaluator

Awesome C#/.NET Expression Evaluator third party-libraries, documentation, and tutorials!
8
star
30

LinqToSql-Plus

LinqToSql Plus is a library that dramatically improves LinqToSql performances by using bulk and batch operations.
6
star
31

docs

5
star
32

learn-orm

learn-orm
C#
5
star
33

sqlite-provider

sqlite-provider
C
2
star