mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add overload
This commit is contained in:
parent
ac95277ced
commit
53f8a4d2b2
@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Reflection;
|
||||
using System.Dynamic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
@ -73,7 +74,11 @@ namespace SqlSugar
|
||||
this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<T> FirstAsync(CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken = token;
|
||||
return FirstAsync();
|
||||
}
|
||||
public async Task<T> FirstAsync()
|
||||
{
|
||||
if (QueryBuilder.OrderByValue.IsNullOrEmpty())
|
||||
@ -97,6 +102,11 @@ namespace SqlSugar
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
public Task<T> FirstAsync(Expression<Func<T, bool>> expression, CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken = token;
|
||||
return FirstAsync(expression);
|
||||
}
|
||||
public async Task<T> FirstAsync(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
_Where(expression);
|
||||
@ -112,11 +122,23 @@ namespace SqlSugar
|
||||
this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<bool> AnyAsync(Expression<Func<T, bool>> expression, CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken = token;
|
||||
return AnyAsync(expression);
|
||||
}
|
||||
|
||||
public async Task<bool> AnyAsync()
|
||||
{
|
||||
return await this.CountAsync() > 0;
|
||||
}
|
||||
|
||||
public Task<int> CountAsync(CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken = token;
|
||||
return CountAsync();
|
||||
}
|
||||
public async Task<int> CountAsync()
|
||||
{
|
||||
if (this.QueryBuilder.Skip == null &&
|
||||
@ -153,6 +175,12 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<int> CountAsync(Expression<Func<T, bool>> expression, CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken = token;
|
||||
return CountAsync(expression);
|
||||
}
|
||||
|
||||
public async Task<TResult> MaxAsync<TResult>(string maxField)
|
||||
{
|
||||
this.Select(string.Format(QueryBuilder.MaxTemplate, maxField));
|
||||
@ -160,11 +188,24 @@ namespace SqlSugar
|
||||
var result = list.SingleOrDefault();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<TResult> MaxAsync<TResult>(string maxField, CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken= token;
|
||||
return MaxAsync<TResult>(maxField);
|
||||
}
|
||||
|
||||
public Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression)
|
||||
{
|
||||
return _MaxAsync<TResult>(expression);
|
||||
}
|
||||
|
||||
public Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression, CancellationToken token)
|
||||
{
|
||||
this.Context.Ado.CancellationToken = token;
|
||||
return MaxAsync(expression);
|
||||
}
|
||||
|
||||
public async Task<TResult> MinAsync<TResult>(string minField)
|
||||
{
|
||||
this.Select(string.Format(QueryBuilder.MinTemplate, minField));
|
||||
|
@ -4,6 +4,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
@ -125,11 +126,14 @@ namespace SqlSugar
|
||||
|
||||
T First();
|
||||
Task<T> FirstAsync();
|
||||
Task<T> FirstAsync(CancellationToken token);
|
||||
T First(Expression<Func<T, bool>> expression);
|
||||
Task<T> FirstAsync(Expression<Func<T, bool>> expression);
|
||||
Task<T> FirstAsync(Expression<Func<T, bool>> expression, CancellationToken token);
|
||||
|
||||
bool Any(Expression<Func<T, bool>> expression);
|
||||
Task<bool> AnyAsync(Expression<Func<T, bool>> expression);
|
||||
Task<bool> AnyAsync(Expression<Func<T, bool>> expression, CancellationToken token);
|
||||
bool Any();
|
||||
Task<bool> AnyAsync();
|
||||
ISugarQueryable<TResult> Select<TResult>(Expression expression);
|
||||
@ -146,12 +150,16 @@ namespace SqlSugar
|
||||
Task ForEachByPageAsync(Action<T> action, int pageIndex, int pageSize, RefAsync<int> totalNumber, int singleMaxReads = 300, System.Threading.CancellationTokenSource cancellationTokenSource = null);
|
||||
int Count();
|
||||
Task<int> CountAsync();
|
||||
Task<int> CountAsync(CancellationToken token);
|
||||
int Count(Expression<Func<T, bool>> expression);
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> expression);
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> expression,CancellationToken token);
|
||||
TResult Max<TResult>(string maxField);
|
||||
Task<TResult> MaxAsync<TResult>(string maxField);
|
||||
Task<TResult> MaxAsync<TResult>(string maxField,CancellationToken token);
|
||||
TResult Max<TResult>(Expression<Func<T, TResult>> expression);
|
||||
Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression);
|
||||
Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression,CancellationToken token);
|
||||
TResult Min<TResult>(string minField);
|
||||
Task<TResult> MinAsync<TResult>(string minField);
|
||||
TResult Min<TResult>(Expression<Func<T, TResult>> expression);
|
||||
|
Loading…
Reference in New Issue
Block a user