mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
-
This commit is contained in:
parent
dbdb762551
commit
2d4c7ee9e2
@ -196,6 +196,7 @@ namespace OrmTest.Demo
|
||||
var sum2 = db.Queryable<Student,School>((st,sc)=>st.SchoolId==sc.Id).Sum((st,sc) => sc.Id);
|
||||
var isAny = db.Queryable<Student>().Where(it => it.Id == -1).Any();
|
||||
var isAny2 = db.Queryable<Student>().Any(it => it.Id == -1);
|
||||
var count = db.Queryable<Student>().Count(it => it.Id >0);
|
||||
var date = db.Queryable<Student>().Where(it => it.CreateTime.Value.Date == DateTime.Now.Date).ToList();
|
||||
var getListByRename = db.Queryable<School>().AS("Student").ToList();
|
||||
var in1 = db.Queryable<Student>().In(it => it.Id, new int[] { 1, 2, 3 }).ToList();
|
||||
|
@ -444,6 +444,13 @@ namespace SqlSugar
|
||||
QueryBuilder.IsCount = false;
|
||||
return reval;
|
||||
}
|
||||
public virtual int Count(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
_Where(expression);
|
||||
var result = Count();
|
||||
this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual TResult Max<TResult>(string maxField)
|
||||
{
|
||||
@ -653,7 +660,16 @@ namespace SqlSugar
|
||||
result.Start();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<int> CountAsync(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
Task<int> result = new Task<int>(() =>
|
||||
{
|
||||
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||
return asyncQueryable.Count(expression);
|
||||
});
|
||||
result.Start();
|
||||
return result;
|
||||
}
|
||||
public Task<TResult> MaxAsync<TResult>(string maxField)
|
||||
{
|
||||
Task<TResult> result = new Task<TResult>(() =>
|
||||
|
@ -75,6 +75,8 @@ namespace SqlSugar
|
||||
|
||||
int Count();
|
||||
Task<int> CountAsync();
|
||||
int Count(Expression<Func<T, bool>> expression);
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> expression);
|
||||
TResult Max<TResult>(string maxField);
|
||||
Task<TResult> MaxAsync<TResult>(string maxField);
|
||||
TResult Max<TResult>(Expression<Func<T, TResult>> expression);
|
||||
|
Loading…
Reference in New Issue
Block a user