using System.Linq.Expressions; using ZeroFramework.DeviceCenter.Domain.Entities; namespace ZeroFramework.DeviceCenter.Domain.Repositories { public static class RepositoryAsyncExtensions { #region Contains public static Task ContainsAsync(this IRepository repository, T item, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.ContainsAsync(repository.Query, item, cancellationToken); } #endregion #region Any/All public static Task AnyAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AnyAsync(repository.Query, predicate, cancellationToken); } public static Task AllAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AllAsync(repository.Query, predicate, cancellationToken); } #endregion #region Count/LongCount public static Task CountAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.CountAsync(repository.Query, cancellationToken); } public static Task CountAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.CountAsync(repository.Query, predicate, cancellationToken); } public static Task LongCountAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.LongCountAsync(repository.Query, cancellationToken); } public static Task LongCountAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.LongCountAsync(repository.Query, predicate, cancellationToken); } #endregion #region First/FirstOrDefault public static Task FirstAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.FirstAsync(repository.Query, cancellationToken); } public static Task FirstAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.FirstAsync(repository.Query, predicate, cancellationToken); } public static Task FirstOrDefaultAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.FirstOrDefaultAsync(repository.Query, cancellationToken); } public static Task FirstOrDefaultAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.FirstOrDefaultAsync(repository.Query, predicate, cancellationToken); } #endregion #region Last/LastOrDefault public static Task LastAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.LastAsync(repository.Query, cancellationToken); } public static Task LastAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.LastAsync(repository.Query, predicate, cancellationToken); } public static Task LastOrDefaultAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.LastOrDefaultAsync(repository.Query, cancellationToken); } public static Task LastOrDefaultAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.LastOrDefaultAsync(repository.Query, predicate, cancellationToken); } #endregion #region Single/SingleOrDefault public static Task SingleAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SingleAsync(repository.Query, cancellationToken); } public static Task SingleAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SingleAsync(repository.Query, predicate, cancellationToken); } public static Task SingleOrDefaultAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SingleOrDefaultAsync(repository.Query, cancellationToken); } public static Task SingleOrDefaultAsync(this IRepository repository, Expression> predicate, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SingleOrDefaultAsync(repository.Query, predicate, cancellationToken); } #endregion #region Min public static Task MinAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.MinAsync(repository.Query, cancellationToken); } public static Task MinAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.MinAsync(repository.Query, selector, cancellationToken); } #endregion #region Max public static Task MaxAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.MaxAsync(repository.Query, cancellationToken); } public static Task MaxAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.MaxAsync(repository.Query, selector, cancellationToken); } #endregion #region Sum public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } public static Task SumAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.SumAsync(repository.Query, selector, cancellationToken); } #endregion #region Average public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } public static Task AverageAsync(this IRepository repository, Expression> selector, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.AverageAsync(repository.Query, selector, cancellationToken); } #endregion #region ToList/Array public static Task> ToListAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.ToListAsync(repository.Query, cancellationToken); } public static Task ToArrayAsync(this IRepository repository, CancellationToken cancellationToken = default) where T : BaseEntity { return repository.AsyncExecuter.ToArrayAsync(repository.Query, cancellationToken); } #endregion } }