mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Update queryable.ToSql()
This commit is contained in:
parent
2babcd9be7
commit
e7ed715874
@ -22,7 +22,6 @@ namespace OrmTest
|
||||
public void Test()
|
||||
{
|
||||
base.db.BeginTran();
|
||||
|
||||
base.GetList(); //调用内部仓储方法
|
||||
base.ChangeRepository<Repository<C2Table>>().GetList();//调用外部仓储
|
||||
|
||||
@ -57,7 +56,8 @@ namespace OrmTest
|
||||
|
||||
var configId = typeof(T).GetCustomAttribute<TenantAttribute>().configId;
|
||||
Context = db.GetConnection(configId);
|
||||
this.db = db;
|
||||
this.db = db;
|
||||
this.db.CodeFirst.InitTables<T>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1177,11 +1177,16 @@ namespace SqlSugar
|
||||
|
||||
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
InitMapping();
|
||||
ToSqlBefore();
|
||||
string sql = QueryBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
||||
if (!QueryBuilder.IsClone)
|
||||
{
|
||||
var newQueryable = this.Clone();
|
||||
newQueryable.QueryBuilder.IsClone = true;
|
||||
return newQueryable.ToSql();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _ToSql();
|
||||
}
|
||||
}
|
||||
public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||
{
|
||||
@ -1464,6 +1469,14 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
public virtual KeyValuePair<string, List<SugarParameter>> _ToSql()
|
||||
{
|
||||
InitMapping();
|
||||
ToSqlBefore();
|
||||
string sql = QueryBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
||||
}
|
||||
private List<T> GetChildList(Expression<Func<T, object>> parentIdExpression, string pkName, List<T> list, object rootValue,bool isRoot=true)
|
||||
{
|
||||
var exp = (parentIdExpression as LambdaExpression).Body;
|
||||
|
@ -646,6 +646,10 @@ namespace SqlSugar
|
||||
|
||||
#endregion
|
||||
|
||||
#region NoCopy
|
||||
internal bool IsClone { get; set; }
|
||||
#endregion
|
||||
|
||||
private string GetTableName(string entityName)
|
||||
{
|
||||
if (this.AsTables != null && this.AsTables.Any(it=>it.Key==entityName))
|
||||
|
Loading…
Reference in New Issue
Block a user