robertcoltheart / task-linq

Extension methods to use LINQ on Task enumerable objets

Repository from Github https://github.comrobertcoltheart/task-linqRepository from Github https://github.comrobertcoltheart/task-linq

TaskLinq

NuGet License

TaskLinq enables you to use method-chaining of LINQ methods when returning enumerable objects from an async method.

IEnumerable<T>, List<T>, and T[] are all supported natively. For other enumerable types, you can call AsEnumerableAsync() to continue using the chained methods.

Usage

Install the package from NuGet with dotnet add package TaskLinq.

Instead of doing this:

var values = (await GetValuesAsync()).ToArray();

you can do this:

var values = await GetValuesAsync().ToArrayAsync();

You can also chain LINQ methods together and await the entire chain:

var values = await GetValuesAsync()
    .WhereAsync(x => x > 1)
    .OrderByAsync(x => x)
    .ToArrayAsync();

For other types inheriting IEnumerable<T> such as HashSet<T> and Dictionary<TKey, TValue>, you can use AsEnumerableAsync() and continue method-chaining:

var values = await GetMyCustomCollection()
    .AsEnumerableAsync()
    .ToArrayAsync();

Get in touch

Raise an issue.

Contributing

Please read CONTRIBUTING.md for details on how to contribute to this project.

License

TaskLinq is released under the MIT License

About

Extension methods to use LINQ on Task enumerable objets

License:MIT License


Languages

Language:C# 99.8%Language:PowerShell 0.1%Language:Shell 0.1%