track/src/SJZY.Track.Domain/IBasicQuery.cs

38 lines
1.1 KiB
C#

namespace SJZY.Track.Domain;
public interface IBasicQuery<T> where T : IEntity
{
/// <summary>
/// top 1
/// </summary>
/// <param name="whereExpression"></param>
/// <returns></returns>
Task<T?> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
Expression<Func<T, TResult>> resultExpression);
/// <summary>
/// get list
/// </summary>
/// <param name="whereExpression"></param>
/// <returns></returns>
Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression);
Task<List<TResult>> GetListAsync<TResult>(Expression<Func<T, bool>> whereExpression,
Expression<Func<T, TResult>> resultExpression);
/// <summary>
/// count
/// </summary>
/// <param name="exp"></param>
/// <returns></returns>
Task<int> CountAsync(Expression<Func<T, bool>> exp);
/// <summary>
/// exists
/// </summary>
/// <param name="exp"></param>
/// <returns></returns>
Task<bool> IsAnyAsync(Expression<Func<T, bool>> exp);
}