mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update Core
This commit is contained in:
parent
fc630ff7fe
commit
0dc6c83b28
@ -159,7 +159,7 @@ namespace OrmTest.Demo
|
|||||||
var getNew = db.Queryable<Student>().Where(it => it.Id == 1).Select(it => new { id = SqlFunc.IIF(it.Id == 0, 1, it.Id), it.Name, it.SchoolId }).ToList();
|
var getNew = db.Queryable<Student>().Where(it => it.Id == 1).Select(it => new { id = SqlFunc.IIF(it.Id == 0, 1, it.Id), it.Name, it.SchoolId }).ToList();
|
||||||
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
||||||
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
||||||
var getSingleOrDefault = db.Queryable<Student>().Single();
|
var getSingleOrDefault = db.Queryable<Student>().Where(it => it.Id == 1).Single();
|
||||||
var getFirstOrDefault = db.Queryable<Student>().First();
|
var getFirstOrDefault = db.Queryable<Student>().First();
|
||||||
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
||||||
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
||||||
|
@ -160,7 +160,7 @@ namespace OrmTest.Demo
|
|||||||
var getNew = db.Queryable<Student>().Where(it => it.Id == 1).Select(it => new { id = SqlFunc.IIF(it.Id == 0, 1, it.Id), it.Name, it.SchoolId }).ToList();
|
var getNew = db.Queryable<Student>().Where(it => it.Id == 1).Select(it => new { id = SqlFunc.IIF(it.Id == 0, 1, it.Id), it.Name, it.SchoolId }).ToList();
|
||||||
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
||||||
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
||||||
var getSingleOrDefault = db.Queryable<Student>().Single();
|
var getSingleOrDefault = db.Queryable<Student>().Where(it=>it.Id==1).Single();
|
||||||
var getFirstOrDefault = db.Queryable<Student>().First();
|
var getFirstOrDefault = db.Queryable<Student>().First();
|
||||||
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
||||||
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
||||||
|
@ -30,6 +30,15 @@ namespace SqlSugar
|
|||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
return Db.ExecuteCommand(sql, paramters);
|
return Db.ExecuteCommand(sql, paramters);
|
||||||
}
|
}
|
||||||
|
public Task<int> ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
Task<int> result = new Task<int>(() =>
|
||||||
|
{
|
||||||
|
IDeleteable<T> asyncDeleteable = CopyDeleteable();
|
||||||
|
return asyncDeleteable.ExecuteCommand();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public IDeleteable<T> AS(string tableName)
|
public IDeleteable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
@ -206,7 +215,6 @@ namespace SqlSugar
|
|||||||
return new KeyValuePair<string, List<SugarParameter>>(sql, paramters);
|
return new KeyValuePair<string, List<SugarParameter>>(sql, paramters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<string> GetPrimaryKeys()
|
private List<string> GetPrimaryKeys()
|
||||||
{
|
{
|
||||||
if (this.Context.IsSystemTablesConfig)
|
if (this.Context.IsSystemTablesConfig)
|
||||||
@ -218,6 +226,7 @@ namespace SqlSugar
|
|||||||
return this.EntityInfo.Columns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName).ToList();
|
return this.EntityInfo.Columns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetIdentityKeys()
|
private List<string> GetIdentityKeys()
|
||||||
{
|
{
|
||||||
if (this.Context.IsSystemTablesConfig)
|
if (this.Context.IsSystemTablesConfig)
|
||||||
@ -229,6 +238,7 @@ namespace SqlSugar
|
|||||||
return this.EntityInfo.Columns.Where(it => it.IsIdentity).Select(it => it.DbColumnName).ToList();
|
return this.EntityInfo.Columns.Where(it => it.IsIdentity).Select(it => it.DbColumnName).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreMapping()
|
private void RestoreMapping()
|
||||||
{
|
{
|
||||||
if (IsAs)
|
if (IsAs)
|
||||||
@ -236,5 +246,24 @@ namespace SqlSugar
|
|||||||
this.Context.MappingTables = OldMappingTableList;
|
this.Context.MappingTables = OldMappingTableList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IDeleteable<T> CopyDeleteable() {
|
||||||
|
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig));
|
||||||
|
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
|
||||||
|
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
|
||||||
|
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;
|
||||||
|
asyncContext.Ado.LogEventCompleted = this.Context.Ado.LogEventCompleted;
|
||||||
|
asyncContext.Ado.ProcessingEventStartingSQL = this.Context.Ado.ProcessingEventStartingSQL;
|
||||||
|
|
||||||
|
var asyncDeleteable = asyncContext.Deleteable<T>();
|
||||||
|
var asyncDeleteBuilder = asyncDeleteable.DeleteBuilder;
|
||||||
|
asyncDeleteBuilder.BigDataFiled = this.DeleteBuilder.BigDataFiled;
|
||||||
|
asyncDeleteBuilder.BigDataInValues = this.DeleteBuilder.BigDataInValues;
|
||||||
|
asyncDeleteBuilder.Parameters = this.DeleteBuilder.Parameters;
|
||||||
|
asyncDeleteBuilder.sql = this.DeleteBuilder.sql;
|
||||||
|
asyncDeleteBuilder.WhereInfos = this.DeleteBuilder.WhereInfos;
|
||||||
|
asyncDeleteBuilder.TableWithString = this.DeleteBuilder.TableWithString;
|
||||||
|
return asyncDeleteable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,51 @@ namespace SqlSugar
|
|||||||
this.Context.EntityProvider.GetProperty<T>(identityKey).SetValue(result,setValue, null);
|
this.Context.EntityProvider.GetProperty<T>(identityKey).SetValue(result,setValue, null);
|
||||||
return idValue>0;
|
return idValue>0;
|
||||||
}
|
}
|
||||||
|
public Task<int> ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
Task<int> result = new Task<int>(() =>
|
||||||
|
{
|
||||||
|
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||||
|
return asyncInsertable.ExecuteCommand();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Task<int> ExecuteReturnIdentityAsync()
|
||||||
|
{
|
||||||
|
Task<int> result = new Task<int>(() =>
|
||||||
|
{
|
||||||
|
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||||
|
return asyncInsertable.ExecuteReturnIdentity();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Task<T> ExecuteReturnEntityAsync()
|
||||||
|
{
|
||||||
|
Task<T> result = new Task<T>(() =>
|
||||||
|
{
|
||||||
|
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||||
|
return asyncInsertable.ExecuteReturnEntity();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Task<bool> ExecuteCommandIdentityIntoEntityAsync()
|
||||||
|
{
|
||||||
|
Task<bool> result = new Task<bool>(() =>
|
||||||
|
{
|
||||||
|
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||||
|
return asyncInsertable.ExecuteCommandIdentityIntoEntity();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Task<long> ExecuteReturnBigIdentityAsync()
|
||||||
|
{
|
||||||
|
Task<long> result = new Task<long>(() =>
|
||||||
|
{
|
||||||
|
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||||
|
return asyncInsertable.ExecuteReturnBigIdentity();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Setting
|
#region Setting
|
||||||
@ -255,6 +300,27 @@ namespace SqlSugar
|
|||||||
this.Context.MappingTables = OldMappingTableList;
|
this.Context.MappingTables = OldMappingTableList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private IInsertable<T> CopyInsertable()
|
||||||
|
{
|
||||||
|
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig));
|
||||||
|
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
|
||||||
|
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
|
||||||
|
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;
|
||||||
|
asyncContext.Ado.LogEventCompleted = this.Context.Ado.LogEventCompleted;
|
||||||
|
asyncContext.Ado.ProcessingEventStartingSQL = this.Context.Ado.ProcessingEventStartingSQL;
|
||||||
|
|
||||||
|
var asyncInsertable = asyncContext.Insertable<T>(this.InsertObjs);
|
||||||
|
var asyncInsertableBuilder = asyncInsertable.InsertBuilder;
|
||||||
|
asyncInsertableBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList;
|
||||||
|
asyncInsertableBuilder.EntityInfo = this.InsertBuilder.EntityInfo;
|
||||||
|
asyncInsertableBuilder.Parameters = this.InsertBuilder.Parameters;
|
||||||
|
asyncInsertableBuilder.sql = this.InsertBuilder.sql;
|
||||||
|
asyncInsertableBuilder.IsNoInsertNull = this.InsertBuilder.IsNoInsertNull;
|
||||||
|
asyncInsertableBuilder.IsReturnIdentity = this.InsertBuilder.IsReturnIdentity;
|
||||||
|
asyncInsertableBuilder.EntityInfo = this.InsertBuilder.EntityInfo;
|
||||||
|
asyncInsertableBuilder.TableWithString = this.InsertBuilder.TableWithString;
|
||||||
|
return asyncInsertable;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@ -28,6 +29,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return this.SqlBuilder.QueryBuilder;
|
return this.SqlBuilder.QueryBuilder;
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
|
this.SqlBuilder.QueryBuilder = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public EntityInfo EntityInfo
|
public EntityInfo EntityInfo
|
||||||
{
|
{
|
||||||
@ -332,16 +336,28 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
QueryBuilder.OrderByValue = QueryBuilder.DefaultOrderByTemplate;
|
QueryBuilder.OrderByValue = QueryBuilder.DefaultOrderByTemplate;
|
||||||
}
|
}
|
||||||
QueryBuilder.Skip = 0;
|
var oldSkip = QueryBuilder.Skip;
|
||||||
QueryBuilder.Take = 1;
|
var oldTake = QueryBuilder.Take;
|
||||||
|
var oldOrderBy = QueryBuilder.OrderByValue;
|
||||||
|
QueryBuilder.Skip = null;
|
||||||
|
QueryBuilder.Take = null;
|
||||||
|
QueryBuilder.OrderByValue = null;
|
||||||
var reval = this.ToList();
|
var reval = this.ToList();
|
||||||
if (reval.IsValuable())
|
QueryBuilder.Skip = oldSkip;
|
||||||
|
QueryBuilder.Take = oldTake;
|
||||||
|
QueryBuilder.OrderByValue = oldOrderBy;
|
||||||
|
if (reval == null || reval.Count == 0)
|
||||||
{
|
{
|
||||||
return reval.SingleOrDefault();
|
return default(T);
|
||||||
|
}
|
||||||
|
else if (reval.Count == 2)
|
||||||
|
{
|
||||||
|
Check.Exception(true, ".Single() result must not exceed one . You can use.First()");
|
||||||
|
return default(T);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return default(T);
|
return reval.SingleOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual T Single(Expression<Func<T, bool>> expression)
|
public virtual T Single(Expression<Func<T, bool>> expression)
|
||||||
@ -377,7 +393,7 @@ namespace SqlSugar
|
|||||||
public virtual bool Any(Expression<Func<T, bool>> expression)
|
public virtual bool Any(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
var result= Any();
|
var result = Any();
|
||||||
this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
|
this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -408,7 +424,7 @@ namespace SqlSugar
|
|||||||
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Select(it=>new{}) Method .");
|
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Select(it=>new{}) Method .");
|
||||||
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0, "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
|
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0, "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
|
||||||
var sql = QueryBuilder.ToSqlString();
|
var sql = QueryBuilder.ToSqlString();
|
||||||
var tableName =this.SqlBuilder.GetPackTable (sql, "MergeTable");
|
var tableName = this.SqlBuilder.GetPackTable(sql, "MergeTable");
|
||||||
return this.Context.Queryable<ExpandoObject>().AS(tableName).Select<T>("*");
|
return this.Context.Queryable<ExpandoObject>().AS(tableName).Select<T>("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,6 +572,253 @@ namespace SqlSugar
|
|||||||
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Async methods
|
||||||
|
public Task<T> SingleAsync()
|
||||||
|
{
|
||||||
|
Task<T> result = new Task<T>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Single();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<T> SingleAsync(Expression<Func<T, bool>> expression)
|
||||||
|
{
|
||||||
|
Task<T> result = new Task<T>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Single(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<T> FirstAsync()
|
||||||
|
{
|
||||||
|
Task<T> result = new Task<T>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.First();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<T> FirstAsync(Expression<Func<T, bool>> expression)
|
||||||
|
{
|
||||||
|
Task<T> result = new Task<T>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.First(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<bool> AnyAsync(Expression<Func<T, bool>> expression)
|
||||||
|
{
|
||||||
|
Task<bool> result = new Task<bool>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Any(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<bool> AnyAsync()
|
||||||
|
{
|
||||||
|
Task<bool> result = new Task<bool>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Any();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> CountAsync()
|
||||||
|
{
|
||||||
|
Task<int> result = new Task<int>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Count();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> MaxAsync<TResult>(string maxField)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Max<TResult>(maxField);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Max<TResult>(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> MinAsync<TResult>(string minField)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Min<TResult>(minField);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> MinAsync<TResult>(Expression<Func<T, TResult>> expression)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Min<TResult>(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> SumAsync<TResult>(string sumField)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Sum<TResult>(sumField);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> SumAsync<TResult>(Expression<Func<T, TResult>> expression)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Sum<TResult>(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> AvgAsync<TResult>(string avgField)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Avg<TResult>(avgField);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult> AvgAsync<TResult>(Expression<Func<T, TResult>> expression)
|
||||||
|
{
|
||||||
|
Task<TResult> result = new Task<TResult>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.Avg<TResult>(expression);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<List<T>> ToListAsync()
|
||||||
|
{
|
||||||
|
Task<List<T>> result = new Task<List<T>>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.ToList();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<string> ToJsonAsync()
|
||||||
|
{
|
||||||
|
Task<string> result = new Task<string>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.ToJson();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<string> ToJsonPageAsync(int pageIndex, int pageSize)
|
||||||
|
{
|
||||||
|
Task<string> result = new Task<string>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.ToJsonPage(pageIndex,pageSize);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<KeyValuePair<string,int>> ToJsonPageAsync(int pageIndex, int pageSize, int totalNumber)
|
||||||
|
{
|
||||||
|
Task<KeyValuePair<string, int>> result = new Task<KeyValuePair<string, int>>(() =>
|
||||||
|
{
|
||||||
|
int totalNumberAsync = 0;
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
var list= asyncQueryable.ToJsonPage(pageIndex, pageSize,ref totalNumberAsync);
|
||||||
|
return new KeyValuePair<string, int>(list, totalNumberAsync);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<DataTable> ToDataTableAsync()
|
||||||
|
{
|
||||||
|
Task<DataTable> result = new Task<DataTable>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.ToDataTable();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<DataTable> ToDataTablePageAsync(int pageIndex, int pageSize)
|
||||||
|
{
|
||||||
|
Task<DataTable> result = new Task<DataTable>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.ToDataTablePage(pageIndex, pageSize);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<KeyValuePair<DataTable, int>> ToDataTablePageAsync(int pageIndex, int pageSize,int totalNumber)
|
||||||
|
{
|
||||||
|
Task<KeyValuePair<DataTable, int>> result = new Task<KeyValuePair<DataTable, int>>(() =>
|
||||||
|
{
|
||||||
|
int totalNumberAsync = 0;
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
var list = asyncQueryable.ToDataTablePage(pageIndex, pageSize, ref totalNumberAsync);
|
||||||
|
return new KeyValuePair<DataTable, int>(list, totalNumberAsync);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<List<T>> ToPageListAsync(int pageIndex, int pageSize)
|
||||||
|
{
|
||||||
|
Task<List<T>> result = new Task<List<T>>(() =>
|
||||||
|
{
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
return asyncQueryable.ToPageList(pageIndex, pageSize);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<KeyValuePair<List<T>, int>> ToPageListAsync(int pageIndex, int pageSize, int totalNumber)
|
||||||
|
{
|
||||||
|
Task<KeyValuePair<List<T>, int>> result = new Task<KeyValuePair<List<T>, int>>(() =>
|
||||||
|
{
|
||||||
|
int totalNumberAsync = 0;
|
||||||
|
ISugarQueryable<T> asyncQueryable = CopyQueryable();
|
||||||
|
var list = asyncQueryable.ToPageList(pageIndex, pageSize, ref totalNumberAsync);
|
||||||
|
return new KeyValuePair<List<T>, int>(list, totalNumberAsync);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Methods
|
#region Private Methods
|
||||||
protected ISugarQueryable<TResult> _Select<TResult>(Expression expression)
|
protected ISugarQueryable<TResult> _Select<TResult>(Expression expression)
|
||||||
@ -681,7 +944,7 @@ namespace SqlSugar
|
|||||||
string sql = sqlObj.Key;
|
string sql = sqlObj.Key;
|
||||||
if (sqlObj.Value.IsValuable())
|
if (sqlObj.Value.IsValuable())
|
||||||
{
|
{
|
||||||
this.SqlBuilder.RepairReplicationParameters(ref sql,sqlObj.Value.ToArray(),100);
|
this.SqlBuilder.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), 100);
|
||||||
this.QueryBuilder.Parameters.AddRange(sqlObj.Value);
|
this.QueryBuilder.Parameters.AddRange(sqlObj.Value);
|
||||||
}
|
}
|
||||||
var isSingle = QueryBuilder.IsSingle();
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
@ -739,15 +1002,37 @@ namespace SqlSugar
|
|||||||
var contextProperty = item.GetType().GetProperty("Context");
|
var contextProperty = item.GetType().GetProperty("Context");
|
||||||
ConnectionConfig config = new ConnectionConfig();
|
ConnectionConfig config = new ConnectionConfig();
|
||||||
config = this.Context.CurrentConnectionConfig;
|
config = this.Context.CurrentConnectionConfig;
|
||||||
var newClient = new SqlSugarClient(config);
|
SqlSugarClient newClient = this.Context.CopyContext(config);
|
||||||
newClient.MappingColumns = this.Context.MappingColumns;
|
|
||||||
newClient.MappingTables = this.Context.MappingTables;
|
|
||||||
newClient.IgnoreColumns = this.Context.IgnoreColumns;
|
|
||||||
contextProperty.SetValue(item, newClient, null);
|
contextProperty.SetValue(item, newClient, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private ISugarQueryable<T> CopyQueryable()
|
||||||
|
{
|
||||||
|
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig));
|
||||||
|
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
|
||||||
|
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
|
||||||
|
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;
|
||||||
|
asyncContext.Ado.LogEventCompleted = this.Context.Ado.LogEventCompleted;
|
||||||
|
asyncContext.Ado.ProcessingEventStartingSQL = this.Context.Ado.ProcessingEventStartingSQL;
|
||||||
|
|
||||||
|
var asyncQueryable = asyncContext.Queryable<ExpandoObject>().Select<T>(string.Empty);
|
||||||
|
var asyncQueryableBuilder = asyncQueryable.QueryBuilder;
|
||||||
|
asyncQueryableBuilder.Take = this.QueryBuilder.Take;
|
||||||
|
asyncQueryableBuilder.Skip = this.QueryBuilder.Skip;
|
||||||
|
asyncQueryableBuilder.SelectValue = this.QueryBuilder.SelectValue;
|
||||||
|
asyncQueryableBuilder.WhereInfos = this.QueryBuilder.WhereInfos;
|
||||||
|
asyncQueryableBuilder.EasyJoinInfos = this.QueryBuilder.EasyJoinInfos;
|
||||||
|
asyncQueryableBuilder.JoinQueryInfos = this.QueryBuilder.JoinQueryInfos;
|
||||||
|
asyncQueryableBuilder.WhereIndex = this.QueryBuilder.WhereIndex;
|
||||||
|
asyncQueryableBuilder.EntityType = this.QueryBuilder.EntityType;
|
||||||
|
asyncQueryableBuilder.EntityName = this.QueryBuilder.EntityName;
|
||||||
|
asyncQueryableBuilder.Parameters = this.QueryBuilder.Parameters;
|
||||||
|
asyncQueryableBuilder.TableShortName = this.QueryBuilder.TableShortName;
|
||||||
|
asyncQueryableBuilder.TableWithString = this.QueryBuilder.TableWithString;
|
||||||
|
return asyncQueryable;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -2152,7 +2437,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T9
|
#region T9
|
||||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8,T9> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9>
|
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>
|
||||||
{
|
{
|
||||||
#region Where
|
#region Where
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, bool>> expression)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, bool>> expression)
|
||||||
@ -2195,7 +2480,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
|
||||||
{
|
{
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -2255,7 +2540,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
|
||||||
{
|
{
|
||||||
if (isWhere)
|
if (isWhere)
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
@ -2305,14 +2590,14 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, TResult>> expression)
|
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
|
||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region OrderBy
|
#region OrderBy
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8,T9> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
@ -2352,7 +2637,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
@ -2400,7 +2685,7 @@ namespace SqlSugar
|
|||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, object>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression)
|
||||||
{
|
{
|
||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -2453,7 +2738,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T10
|
#region T10
|
||||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>
|
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>
|
||||||
{
|
{
|
||||||
#region Where
|
#region Where
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, bool>> expression)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, bool>> expression)
|
||||||
@ -2501,7 +2786,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
|
||||||
{
|
{
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -2567,7 +2852,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
|
||||||
{
|
{
|
||||||
if (isWhere)
|
if (isWhere)
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
@ -2620,7 +2905,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, TResult>> expression)
|
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
|
||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
@ -2672,7 +2957,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
@ -2680,7 +2965,7 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GroupBy
|
#region GroupBy
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> GroupBy(Expression<Func<T, object>> expression)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, object>> expression)
|
||||||
{
|
{
|
||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -2725,7 +3010,7 @@ namespace SqlSugar
|
|||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, object>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression)
|
||||||
{
|
{
|
||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -2778,7 +3063,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T11
|
#region T11
|
||||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
|
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
|
||||||
{
|
{
|
||||||
#region Where
|
#region Where
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, bool>> expression)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, bool>> expression)
|
||||||
@ -2831,7 +3116,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> expression)
|
||||||
{
|
{
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -2903,7 +3188,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> expression)
|
||||||
{
|
{
|
||||||
if (isWhere)
|
if (isWhere)
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
@ -2960,7 +3245,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, TResult>> expression)
|
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
|
||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
@ -3017,7 +3302,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
@ -3075,7 +3360,7 @@ namespace SqlSugar
|
|||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, object>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression)
|
||||||
{
|
{
|
||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -3128,7 +3413,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T12
|
#region T12
|
||||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12>
|
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
|
||||||
{
|
{
|
||||||
#region Where
|
#region Where
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, bool>> expression)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, bool>> expression)
|
||||||
@ -3186,7 +3471,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> expression)
|
||||||
{
|
{
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -3264,7 +3549,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, bool>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> expression)
|
||||||
{
|
{
|
||||||
if (isWhere)
|
if (isWhere)
|
||||||
_Where(expression);
|
_Where(expression);
|
||||||
@ -3325,7 +3610,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, TResult>> expression)
|
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>> expression)
|
||||||
{
|
{
|
||||||
return _Select<TResult>(expression);
|
return _Select<TResult>(expression);
|
||||||
}
|
}
|
||||||
@ -3387,7 +3672,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
@ -3450,7 +3735,7 @@ namespace SqlSugar
|
|||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, object>> expression)
|
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object>> expression)
|
||||||
{
|
{
|
||||||
_GroupBy(expression);
|
_GroupBy(expression);
|
||||||
return this;
|
return this;
|
||||||
@ -3477,21 +3762,24 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region In
|
#region In
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues) {
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
var isSingle = QueryBuilder.IsSingle();
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
var fieldName = lamResult.GetResultString();
|
var fieldName = lamResult.GetResultString();
|
||||||
In(fieldName, inValues);
|
In(fieldName, inValues);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues) {
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
var isSingle = QueryBuilder.IsSingle();
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
var fieldName = lamResult.GetResultString();
|
var fieldName = lamResult.GetResultString();
|
||||||
In(fieldName, inValues);
|
In(fieldName, inValues);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression) {
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
var sqlObj = childQueryExpression.ToSql();
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
_InQueryable(expression, sqlObj);
|
_InQueryable(expression, sqlObj);
|
||||||
return this;
|
return this;
|
||||||
|
@ -8,12 +8,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class UpdateableProvider<T> : IUpdateable<T>
|
public class UpdateableProvider<T> : IUpdateable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
public SqlSugarClient Context { get; internal set; }
|
public SqlSugarClient Context { get; internal set; }
|
||||||
public EntityInfo EntityInfo { get; internal set; }
|
public EntityInfo EntityInfo { get; internal set; }
|
||||||
public ISqlBuilder SqlBuilder { get; internal set; }
|
public ISqlBuilder SqlBuilder { get; internal set; }
|
||||||
public UpdateBuilder UpdateBuilder { get; internal set; }
|
public UpdateBuilder UpdateBuilder { get; set; }
|
||||||
public IAdo Ado { get { return Context.Ado; } }
|
public IAdo Ado { get { return Context.Ado; } }
|
||||||
public T[] UpdateObjs { get; set; }
|
public T[] UpdateObjs { get; set; }
|
||||||
public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } }
|
public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } }
|
||||||
@ -33,6 +33,15 @@ namespace SqlSugar
|
|||||||
Check.Exception(UpdateBuilder.WhereValues.IsNullOrEmpty() && GetPrimaryKeys().IsNullOrEmpty(), "You cannot have no primary key and no conditions");
|
Check.Exception(UpdateBuilder.WhereValues.IsNullOrEmpty() && GetPrimaryKeys().IsNullOrEmpty(), "You cannot have no primary key and no conditions");
|
||||||
return this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
return this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
||||||
}
|
}
|
||||||
|
public Task<int> ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
Task<int> result = new Task<int>(() =>
|
||||||
|
{
|
||||||
|
IUpdateable<T> asyncUpdateable = CopyUpdateable();
|
||||||
|
return asyncUpdateable.ExecuteCommand();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public IUpdateable<T> AS(string tableName)
|
public IUpdateable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
@ -268,7 +277,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
private List<string> GetPrimaryKeys()
|
private List<string> GetPrimaryKeys()
|
||||||
{
|
{
|
||||||
if (this.WhereColumnList.IsValuable()) {
|
if (this.WhereColumnList.IsValuable())
|
||||||
|
{
|
||||||
return this.WhereColumnList;
|
return this.WhereColumnList;
|
||||||
}
|
}
|
||||||
if (this.Context.IsSystemTablesConfig)
|
if (this.Context.IsSystemTablesConfig)
|
||||||
@ -298,5 +308,28 @@ namespace SqlSugar
|
|||||||
this.Context.MappingTables = OldMappingTableList;
|
this.Context.MappingTables = OldMappingTableList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private IUpdateable<T> CopyUpdateable()
|
||||||
|
{
|
||||||
|
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig));
|
||||||
|
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
|
||||||
|
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
|
||||||
|
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;
|
||||||
|
asyncContext.Ado.LogEventCompleted = this.Context.Ado.LogEventCompleted;
|
||||||
|
asyncContext.Ado.ProcessingEventStartingSQL = this.Context.Ado.ProcessingEventStartingSQL;
|
||||||
|
|
||||||
|
var asyncUpdateable = asyncContext.Updateable<T>(this.UpdateObjs);
|
||||||
|
var asyncUpdateableBuilder = asyncUpdateable.UpdateBuilder;
|
||||||
|
asyncUpdateableBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList;
|
||||||
|
asyncUpdateableBuilder.IsNoUpdateNull = this.UpdateBuilder.IsNoUpdateNull;
|
||||||
|
asyncUpdateableBuilder.Parameters = this.UpdateBuilder.Parameters;
|
||||||
|
asyncUpdateableBuilder.sql = this.UpdateBuilder.sql;
|
||||||
|
asyncUpdateableBuilder.WhereValues = this.UpdateBuilder.WhereValues;
|
||||||
|
asyncUpdateableBuilder.TableWithString = this.UpdateBuilder.TableWithString;
|
||||||
|
asyncUpdateableBuilder.TableName = this.UpdateBuilder.TableName;
|
||||||
|
asyncUpdateableBuilder.PrimaryKeys = this.UpdateBuilder.PrimaryKeys;
|
||||||
|
asyncUpdateableBuilder.IsOffIdentity = this.UpdateBuilder.IsOffIdentity;
|
||||||
|
asyncUpdateableBuilder.SetValues = this.UpdateBuilder.SetValues;
|
||||||
|
return asyncUpdateable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace SqlSugar
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///DbType.SqlServer Or Other
|
///DbType.SqlServer Or Other
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DbType { get; set; }
|
public DbType DbType { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///Database Connection string
|
///Database Connection string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SqlSugar
|
|
||||||
{
|
|
||||||
public partial class DbType
|
|
||||||
{
|
|
||||||
public const string MySql = "MySql";
|
|
||||||
public const string SqlServer = "SqlServer";
|
|
||||||
public const string Sqlite = "Sqlite";
|
|
||||||
public const string Oracle = "Oracle";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -8,6 +9,7 @@ namespace SqlSugar
|
|||||||
public class ModelContext
|
public class ModelContext
|
||||||
{
|
{
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
[JsonIgnore]
|
||||||
public SqlSugarClient Context { get; set; }
|
public SqlSugarClient Context { get; set; }
|
||||||
public ISugarQueryable<T> CreateMapping<T>() where T : class, new()
|
public ISugarQueryable<T> CreateMapping<T>() where T : class, new()
|
||||||
{
|
{
|
||||||
|
15
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Enum/DbType.cs
Normal file
15
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Enum/DbType.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public enum DbType
|
||||||
|
{
|
||||||
|
MySql ,
|
||||||
|
SqlServer,
|
||||||
|
Sqlite,
|
||||||
|
Oracle
|
||||||
|
}
|
||||||
|
}
|
@ -71,6 +71,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Boolean;
|
this.DbType = System.Data.DbType.Boolean;
|
||||||
}
|
}
|
||||||
|
else if (type == UtilConstants.StringType)
|
||||||
|
{
|
||||||
|
this.DbType = System.Data.DbType.String;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public SugarParameter(string name, object value, bool isOutput)
|
public SugarParameter(string name, object value, bool isOutput)
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T> result = CreateInstance<T, ISugarQueryable<T>>(className);
|
ISugarQueryable<T> result = CreateInstance<T, ISugarQueryable<T>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2> result = CreateInstance<T, T2, ISugarQueryable<T, T2>>(className);
|
ISugarQueryable<T, T2> result = CreateInstance<T, T2, ISugarQueryable<T, T2>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3> result = CreateInstance<T, T2, T3, ISugarQueryable<T, T2, T3>>(className);
|
ISugarQueryable<T, T2, T3> result = CreateInstance<T, T2, T3, ISugarQueryable<T, T2, T3>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -57,35 +57,35 @@ namespace SqlSugar
|
|||||||
public static ISugarQueryable<T, T2, T3, T4> GetQueryable<T, T2, T3, T4>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4> GetQueryable<T, T2, T3, T4>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4> result = CreateInstance<T, T2, T3, T4, ISugarQueryable<T, T2, T3, T4>>(className);
|
ISugarQueryable<T, T2, T3, T4> result = CreateInstance<T, T2, T3, T4, ISugarQueryable<T, T2, T3, T4>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5> GetQueryable<T, T2, T3, T4, T5>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5> GetQueryable<T, T2, T3, T4, T5>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5> result = CreateInstance<T, T2, T3, T4, T5, ISugarQueryable<T, T2, T3, T4, T5>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5> result = CreateInstance<T, T2, T3, T4, T5, ISugarQueryable<T, T2, T3, T4, T5>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6> GetQueryable<T, T2, T3, T4, T5, T6>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6> GetQueryable<T, T2, T3, T4, T5, T6>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6> result = CreateInstance<T, T2, T3, T4, T5, T6, ISugarQueryable<T, T2, T3, T4, T5, T6>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6> result = CreateInstance<T, T2, T3, T4, T5, T6, ISugarQueryable<T, T2, T3, T4, T5, T6>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GetQueryable<T, T2, T3, T4, T5, T6, T7>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GetQueryable<T, T2, T3, T4, T5, T6, T7>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, ISugarQueryable<T, T2, T3, T4, T5, T6, T7>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, ISugarQueryable<T, T2, T3, T4, T5, T6, T7>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -94,28 +94,28 @@ namespace SqlSugar
|
|||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8,T9, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8,T9, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(ConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType.ToString(), className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(className);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> result = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(className);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -131,23 +131,23 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QueryBuilder result = CreateInstance<QueryBuilder>(GetClassName(currentConnectionConfig.DbType, "QueryBuilder"));
|
QueryBuilder result = CreateInstance<QueryBuilder>(GetClassName(currentConnectionConfig.DbType.ToString(), "QueryBuilder"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static InsertBuilder GetInsertBuilder(ConnectionConfig currentConnectionConfig)
|
public static InsertBuilder GetInsertBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
InsertBuilder result = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"));
|
InsertBuilder result = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType.ToString(), "InsertBuilder"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static UpdateBuilder GetUpdateBuilder(ConnectionConfig currentConnectionConfig)
|
public static UpdateBuilder GetUpdateBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
UpdateBuilder result = CreateInstance<UpdateBuilder>(GetClassName(currentConnectionConfig.DbType, "UpdateBuilder"));
|
UpdateBuilder result = CreateInstance<UpdateBuilder>(GetClassName(currentConnectionConfig.DbType.ToString(), "UpdateBuilder"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static DeleteBuilder GetDeleteBuilder(ConnectionConfig currentConnectionConfig)
|
public static DeleteBuilder GetDeleteBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
DeleteBuilder result = CreateInstance<DeleteBuilder>(GetClassName(currentConnectionConfig.DbType, "DeleteBuilder"));
|
DeleteBuilder result = CreateInstance<DeleteBuilder>(GetClassName(currentConnectionConfig.DbType.ToString(), "DeleteBuilder"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,44 +159,44 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ILambdaExpressions result = CreateInstance<ILambdaExpressions>(GetClassName(currentConnectionConfig.DbType, "ExpressionContext"));
|
ILambdaExpressions result = CreateInstance<ILambdaExpressions>(GetClassName(currentConnectionConfig.DbType.ToString(), "ExpressionContext"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ISqlBuilder GetSqlbuilder(ConnectionConfig currentConnectionConfig)
|
public static ISqlBuilder GetSqlbuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
ISqlBuilder result = CreateInstance<ISqlBuilder>(GetClassName(currentConnectionConfig.DbType, "Builder"));
|
ISqlBuilder result = CreateInstance<ISqlBuilder>(GetClassName(currentConnectionConfig.DbType.ToString(), "Builder"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDbBind GetDbBind(ConnectionConfig currentConnectionConfig)
|
public static IDbBind GetDbBind(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
IDbBind result = CreateInstance<IDbBind>(GetClassName(currentConnectionConfig.DbType, "DbBind"));
|
IDbBind result = CreateInstance<IDbBind>(GetClassName(currentConnectionConfig.DbType.ToString(), "DbBind"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDbMaintenance GetDbMaintenance(ConnectionConfig currentConnectionConfig)
|
public static IDbMaintenance GetDbMaintenance(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
IDbMaintenance result = CreateInstance<IDbMaintenance>(GetClassName(currentConnectionConfig.DbType, "DbMaintenance"));
|
IDbMaintenance result = CreateInstance<IDbMaintenance>(GetClassName(currentConnectionConfig.DbType.ToString(), "DbMaintenance"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDbFirst GetDbFirst(ConnectionConfig currentConnectionConfig)
|
public static IDbFirst GetDbFirst(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
IDbFirst result = CreateInstance<IDbFirst>(GetClassName(currentConnectionConfig.DbType, "DbFirst"));
|
IDbFirst result = CreateInstance<IDbFirst>(GetClassName(currentConnectionConfig.DbType.ToString(), "DbFirst"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICodeFirst GetCodeFirst(ConnectionConfig currentConnectionConfig)
|
public static ICodeFirst GetCodeFirst(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
ICodeFirst result = CreateInstance<ICodeFirst>(GetClassName(currentConnectionConfig.DbType, "CodeFirst"));
|
ICodeFirst result = CreateInstance<ICodeFirst>(GetClassName(currentConnectionConfig.DbType.ToString(), "CodeFirst"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IAdo GetAdo(ConnectionConfig currentConnectionConfig)
|
public static IAdo GetAdo(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
IAdo result = CreateInstance<IAdo>(GetClassName(currentConnectionConfig.DbType, "Provider"));
|
IAdo result = CreateInstance<IAdo>(GetClassName(currentConnectionConfig.DbType.ToString(), "Provider"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public interface IDeleteable<T> where T : class, new()
|
public interface IDeleteable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
|
DeleteBuilder DeleteBuilder { get; set; }
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
|
Task<int> ExecuteCommandAsync();
|
||||||
IDeleteable<T> AS(string tableName);
|
IDeleteable<T> AS(string tableName);
|
||||||
IDeleteable<T> With(string lockString);
|
IDeleteable<T> With(string lockString);
|
||||||
IDeleteable<T> Where(T deleteObj);
|
IDeleteable<T> Where(T deleteObj);
|
||||||
|
@ -5,12 +5,15 @@ using System.Data.SqlClient;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public partial interface ISugarQueryable<T>
|
public partial interface ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
SqlSugarClient Context { get; set; }
|
SqlSugarClient Context { get; set; }
|
||||||
ISqlBuilder SqlBuilder { get; set; }
|
ISqlBuilder SqlBuilder { get; set; }
|
||||||
|
QueryBuilder QueryBuilder { get; set; }
|
||||||
|
|
||||||
ISugarQueryable<T> AS<T2>(string tableName);
|
ISugarQueryable<T> AS<T2>(string tableName);
|
||||||
ISugarQueryable<T> AS(string tableName);
|
ISugarQueryable<T> AS(string tableName);
|
||||||
@ -51,13 +54,19 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<T> Take(int num);
|
ISugarQueryable<T> Take(int num);
|
||||||
|
|
||||||
T Single();
|
T Single();
|
||||||
|
Task<T> SingleAsync();
|
||||||
T Single(Expression<Func<T, bool>> expression);
|
T Single(Expression<Func<T, bool>> expression);
|
||||||
|
Task<T> SingleAsync(Expression<Func<T, bool>> expression);
|
||||||
|
|
||||||
T First();
|
T First();
|
||||||
|
Task<T> FirstAsync();
|
||||||
T First(Expression<Func<T, bool>> expression);
|
T First(Expression<Func<T, bool>> expression);
|
||||||
|
Task<T> FirstAsync(Expression<Func<T, bool>> expression);
|
||||||
|
|
||||||
bool Any(Expression<Func<T, bool>> expression);
|
bool Any(Expression<Func<T, bool>> expression);
|
||||||
|
Task<bool> AnyAsync(Expression<Func<T, bool>> expression);
|
||||||
bool Any();
|
bool Any();
|
||||||
|
Task<bool> AnyAsync();
|
||||||
|
|
||||||
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
|
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
ISugarQueryable<TResult> Select<TResult>(string select);
|
ISugarQueryable<TResult> Select<TResult>(string select);
|
||||||
@ -65,31 +74,47 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<T> MergeTable();
|
ISugarQueryable<T> MergeTable();
|
||||||
|
|
||||||
int Count();
|
int Count();
|
||||||
|
Task<int> CountAsync();
|
||||||
TResult Max<TResult>(string maxField);
|
TResult Max<TResult>(string maxField);
|
||||||
|
Task<TResult> MaxAsync<TResult>(string maxField);
|
||||||
TResult Max<TResult>(Expression<Func<T, TResult>> expression);
|
TResult Max<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
|
Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
TResult Min<TResult>(string minField);
|
TResult Min<TResult>(string minField);
|
||||||
|
Task<TResult> MinAsync<TResult>(string minField);
|
||||||
TResult Min<TResult>(Expression<Func<T, TResult>> expression);
|
TResult Min<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
|
Task<TResult> MinAsync<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
TResult Sum<TResult>(string sumField);
|
TResult Sum<TResult>(string sumField);
|
||||||
|
Task<TResult> SumAsync<TResult>(string sumField);
|
||||||
TResult Sum<TResult>(Expression<Func<T, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
|
Task<TResult> SumAsync<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
TResult Avg<TResult>(string avgField);
|
TResult Avg<TResult>(string avgField);
|
||||||
|
Task<TResult> AvgAsync<TResult>(string avgField);
|
||||||
TResult Avg<TResult>(Expression<Func<T, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
|
Task<TResult> AvgAsync<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
|
|
||||||
List<T> ToList();
|
List<T> ToList();
|
||||||
|
Task<List<T>> ToListAsync();
|
||||||
|
|
||||||
string ToJson();
|
string ToJson();
|
||||||
|
Task<string> ToJsonAsync();
|
||||||
string ToJsonPage(int pageIndex, int pageSize);
|
string ToJsonPage(int pageIndex, int pageSize);
|
||||||
|
Task<string> ToJsonPageAsync(int pageIndex, int pageSize);
|
||||||
string ToJsonPage(int pageIndex, int pageSize, ref int totalNumber);
|
string ToJsonPage(int pageIndex, int pageSize, ref int totalNumber);
|
||||||
|
Task<KeyValuePair<string,int>> ToJsonPageAsync(int pageIndex, int pageSize, int totalNumber);
|
||||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
|
|
||||||
|
|
||||||
DataTable ToDataTable();
|
DataTable ToDataTable();
|
||||||
|
Task<DataTable> ToDataTableAsync();
|
||||||
DataTable ToDataTablePage(int pageIndex, int pageSize);
|
DataTable ToDataTablePage(int pageIndex, int pageSize);
|
||||||
|
Task<DataTable> ToDataTablePageAsync(int pageIndex, int pageSize);
|
||||||
DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber);
|
DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber);
|
||||||
|
Task<KeyValuePair<DataTable,int>> ToDataTablePageAsync(int pageIndex, int pageSize, int totalNumber);
|
||||||
|
|
||||||
List<T> ToPageList(int pageIndex, int pageSize);
|
List<T> ToPageList(int pageIndex, int pageSize);
|
||||||
|
Task<List<T>> ToPageListAsync(int pageIndex, int pageSize);
|
||||||
List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber);
|
List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber);
|
||||||
|
Task<KeyValuePair<List<T>,int>> ToPageListAsync(int pageIndex, int pageSize, int totalNumber);
|
||||||
void Clear();
|
void Clear();
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2> : ISugarQueryable<T>
|
||||||
|
@ -7,9 +7,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public interface IUpdateable<T>
|
public interface IUpdateable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
|
UpdateBuilder UpdateBuilder { get; set; }
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
|
Task<int> ExecuteCommandAsync();
|
||||||
IUpdateable<T> AS(string tableName);
|
IUpdateable<T> AS(string tableName);
|
||||||
IUpdateable<T> With(string lockString);
|
IUpdateable<T> With(string lockString);
|
||||||
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
|
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
|
||||||
|
@ -9,11 +9,17 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public interface IInsertable<T>
|
public interface IInsertable<T>
|
||||||
{
|
{
|
||||||
|
InsertBuilder InsertBuilder { get; set; }
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
|
Task<int> ExecuteCommandAsync();
|
||||||
int ExecuteReturnIdentity();
|
int ExecuteReturnIdentity();
|
||||||
|
Task<int> ExecuteReturnIdentityAsync();
|
||||||
T ExecuteReturnEntity();
|
T ExecuteReturnEntity();
|
||||||
|
Task<T> ExecuteReturnEntityAsync();
|
||||||
bool ExecuteCommandIdentityIntoEntity();
|
bool ExecuteCommandIdentityIntoEntity();
|
||||||
|
Task<bool> ExecuteCommandIdentityIntoEntityAsync();
|
||||||
long ExecuteReturnBigIdentity();
|
long ExecuteReturnBigIdentity();
|
||||||
|
Task<long> ExecuteReturnBigIdentityAsync();
|
||||||
IInsertable<T> AS(string tableName);
|
IInsertable<T> AS(string tableName);
|
||||||
IInsertable<T> With(string lockString);
|
IInsertable<T> With(string lockString);
|
||||||
IInsertable<T> InsertColumns(Expression<Func<T, object>> columns);
|
IInsertable<T> InsertColumns(Expression<Func<T, object>> columns);
|
||||||
|
@ -12,7 +12,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string sql = @"SELECT Sysobjects.name AS TableName,
|
string sql = @"SELECT sysobjects.name AS TableName,
|
||||||
syscolumns.Id AS TableId,
|
syscolumns.Id AS TableId,
|
||||||
syscolumns.name AS DbColumnName,
|
syscolumns.name AS DbColumnName,
|
||||||
systypes.name AS DataType,
|
systypes.name AS DataType,
|
||||||
@ -60,7 +60,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return @"SELECT s.Name,Convert(varchar(max),tbp.value) as Description
|
return @"SELECT s.Name,Convert(varchar(max),tbp.value) as Description
|
||||||
FROM sysobjects s
|
FROM sysobjects s
|
||||||
LEFT JOIN sys.extended_properties as tbp ON s.id=tbp.major_id and tbp.minor_id=0 WHERE s.xtype IN('U') AND (tbp.Name='MS_Description' OR tbp.Name is null)";
|
LEFT JOIN sys.extended_properties as tbp ON s.id=tbp.major_id and tbp.minor_id=0 AND (tbp.Name='MS_Description' OR tbp.Name is null) WHERE s.xtype IN('U') ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetViewInfoListSql
|
protected override string GetViewInfoListSql
|
||||||
@ -69,7 +69,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return @"SELECT s.Name,Convert(varchar(max),tbp.value) as Description
|
return @"SELECT s.Name,Convert(varchar(max),tbp.value) as Description
|
||||||
FROM sysobjects s
|
FROM sysobjects s
|
||||||
LEFT JOIN sys.extended_properties as tbp ON s.id=tbp.major_id and tbp.minor_id=0 WHERE s.xtype IN('V') AND (tbp.Name='MS_Description' OR tbp.Name is null)";
|
LEFT JOIN sys.extended_properties as tbp ON s.id=tbp.major_id and tbp.minor_id=0 AND (tbp.Name='MS_Description' OR tbp.Name is null) WHERE s.xtype IN('V') ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>4.5.0.2</Version>
|
<Version>4.5.1</Version>
|
||||||
<Copyright>sunkaixuan</Copyright>
|
<Copyright>sunkaixuan</Copyright>
|
||||||
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
|
||||||
<PackageLicenseUrl></PackageLicenseUrl>
|
<PackageLicenseUrl></PackageLicenseUrl>
|
||||||
|
@ -565,6 +565,14 @@ namespace SqlSugar
|
|||||||
this.Ado.Dispose();
|
this.Ado.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal SqlSugarClient CopyContext(ConnectionConfig config)
|
||||||
|
{
|
||||||
|
var newClient = new SqlSugarClient(config);
|
||||||
|
newClient.MappingColumns = this.Context.MappingColumns;
|
||||||
|
newClient.MappingTables = this.Context.MappingTables;
|
||||||
|
newClient.IgnoreColumns = this.Context.IgnoreColumns;
|
||||||
|
return newClient;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>sqlSugarCore</id>
|
<id>sqlSugarCore</id>
|
||||||
<version>4.5.0.2</version>
|
<version>4.5.1</version>
|
||||||
<authors>sunkaixuan</authors>
|
<authors>sunkaixuan</authors>
|
||||||
<owners>Landa</owners>
|
<owners>Landa</owners>
|
||||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||||
|
Binary file not shown.
@ -166,7 +166,7 @@ namespace OrmTest.Demo
|
|||||||
var getNew = db.Queryable<Student>().Where(it => it.Id == 1).Select(it => new { id = SqlFunc.IIF(it.Id == 0, 1, it.Id), it.Name, it.SchoolId }).ToList();
|
var getNew = db.Queryable<Student>().Where(it => it.Id == 1).Select(it => new { id = SqlFunc.IIF(it.Id == 0, 1, it.Id), it.Name, it.SchoolId }).ToList();
|
||||||
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
||||||
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
||||||
var getSingleOrDefault = db.Queryable<Student>().Single();
|
var getSingleOrDefault = db.Queryable<Student>().Where(it => it.Id == 1).Single();
|
||||||
var getFirstOrDefault = db.Queryable<Student>().First();
|
var getFirstOrDefault = db.Queryable<Student>().First();
|
||||||
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
||||||
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
||||||
|
Loading…
Reference in New Issue
Block a user