Add SimpleClient.GetFirst

This commit is contained in:
sunkaixuna 2021-10-06 15:09:52 +08:00
parent 6d34ad1607
commit 1945600c8a
2 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,7 @@ namespace SqlSugar
List<T> GetPageList(List<IConditionalModel> conditionalList, PageModel page); List<T> GetPageList(List<IConditionalModel> conditionalList, PageModel page);
List<T> GetPageList(List<IConditionalModel> conditionalList, PageModel page, Expression<Func<T, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc); List<T> GetPageList(List<IConditionalModel> conditionalList, PageModel page, Expression<Func<T, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc);
T GetSingle(Expression<Func<T, bool>> whereExpression); T GetSingle(Expression<Func<T, bool>> whereExpression);
T GetFirst(Expression<Func<T, bool>> whereExpression);
bool Insert(T insertObj); bool Insert(T insertObj);
bool InsertRange(List<T> insertObjs); bool InsertRange(List<T> insertObjs);
bool InsertRange(T[] insertObjs); bool InsertRange(T[] insertObjs);
@ -63,6 +64,7 @@ namespace SqlSugar
Task<List<T>> GetPageListAsync(List<IConditionalModel> conditionalList, PageModel page); Task<List<T>> GetPageListAsync(List<IConditionalModel> conditionalList, PageModel page);
Task<List<T>> GetPageListAsync(List<IConditionalModel> conditionalList, PageModel page, Expression<Func<T, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc); Task<List<T>> GetPageListAsync(List<IConditionalModel> conditionalList, PageModel page, Expression<Func<T, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc);
Task<T> GetSingleAsync(Expression<Func<T, bool>> whereExpression); Task<T> GetSingleAsync(Expression<Func<T, bool>> whereExpression);
Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
Task<bool> InsertAsync(T insertObj); Task<bool> InsertAsync(T insertObj);
Task<bool> InsertRangeAsync(List<T> insertObjs); Task<bool> InsertRangeAsync(List<T> insertObjs);
Task<bool> InsertRangeAsync(T[] insertObjs); Task<bool> InsertRangeAsync(T[] insertObjs);

View File

@ -98,6 +98,10 @@ namespace SqlSugar
{ {
return Context.Queryable<T>().Single(whereExpression); return Context.Queryable<T>().Single(whereExpression);
} }
public T GetFirst(Expression<Func<T, bool>> whereExpression)
{
return Context.Queryable<T>().First(whereExpression);
}
public virtual List<T> GetPageList(Expression<Func<T, bool>> whereExpression, PageModel page) public virtual List<T> GetPageList(Expression<Func<T, bool>> whereExpression, PageModel page)
{ {
int count = 0; int count = 0;
@ -224,6 +228,10 @@ namespace SqlSugar
{ {
return Context.Queryable<T>().SingleAsync(whereExpression); return Context.Queryable<T>().SingleAsync(whereExpression);
} }
public Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression)
{
return Context.Queryable<T>().FirstAsync(whereExpression);
}
public virtual async Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, PageModel page) public virtual async Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, PageModel page)
{ {
RefAsync<int> count = 0; RefAsync<int> count = 0;