Files
ersatztv/ErsatzTV.Infrastructure/Extensions/QueryableExtensions.cs
T
Jason DoveandGitHub 1ab98578ab refactor namespaces and imports (#670)
* re-namespace

* optimize usings

* more usings

* more of the same

* more implicit/global usings

* cleanup all usings

* minor fixes
2022-03-03 15:36:07 -06:00

13 lines
455 B
C#

using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Infrastructure.Extensions;
public static class QueryableExtensions
{
public static async Task<Option<T>> SelectOneAsync<T, TKey>(
this IQueryable<T> enumerable,
Expression<Func<T, TKey>> keySelector,
Expression<Func<T, bool>> predicate) where T : class =>
await enumerable.OrderBy(keySelector).FirstOrDefaultAsync(predicate);
}