Add Queryable.InSingleAsync

This commit is contained in:
sunkaixuan 2019-05-31 17:18:08 +08:00
parent cd7985db6c
commit 19ab13134a
2 changed files with 8 additions and 0 deletions

View File

@ -824,6 +824,13 @@ namespace SqlSugar
return result;
}
#region Async methods
public virtual async Task<T> InSingleAsync(object pkValue)
{
Check.Exception(this.QueryBuilder.SelectValue.HasValue(), "'InSingle' and' Select' can't be used together,You can use .Select(it=>...).Single(it.id==1)");
var list =await In(pkValue).ToListAsync();
if (list == null) return default(T);
else return list.SingleOrDefault();
}
public async Task<T> SingleAsync()
{
if (QueryBuilder.OrderByValue.IsNullOrEmpty())

View File

@ -54,6 +54,7 @@ namespace SqlSugar
ISugarQueryable<T> WhereIF(bool isWhere, string whereString, object parameters = null);
T InSingle(object pkValue);
Task<T> InSingleAsync(object pkValue);
ISugarQueryable<T> In<TParamter>(params TParamter[] pkValues);
ISugarQueryable<T> In<FieldType>(string InFieldName, params FieldType[] inValues);
ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);