Update Core

This commit is contained in:
sunkaixuan
2019-03-03 19:35:19 +08:00
parent 6b95769754
commit fb93a36218
5 changed files with 44 additions and 2 deletions

View File

@@ -388,6 +388,10 @@ namespace SqlSugar
asyncDeleteBuilder.sql = this.DeleteBuilder.sql;
asyncDeleteBuilder.WhereInfos = this.DeleteBuilder.WhereInfos;
asyncDeleteBuilder.TableWithString = this.DeleteBuilder.TableWithString;
if (this.RemoveCacheFunc != null)
{
asyncDeleteable.RemoveDataCache();
}
return asyncDeleteable;
}

View File

@@ -439,6 +439,10 @@ namespace SqlSugar
asyncInsertableBuilder.IsReturnIdentity = this.InsertBuilder.IsReturnIdentity;
asyncInsertableBuilder.EntityInfo = this.InsertBuilder.EntityInfo;
asyncInsertableBuilder.TableWithString = this.InsertBuilder.TableWithString;
if (this.RemoveCacheFunc != null)
{
asyncInsertable.RemoveDataCache();
}
return asyncInsertable;
}

View File

@@ -540,6 +540,10 @@ namespace SqlSugar
asyncUpdateableBuilder.PrimaryKeys = this.UpdateBuilder.PrimaryKeys;
asyncUpdateableBuilder.IsOffIdentity = this.UpdateBuilder.IsOffIdentity;
asyncUpdateableBuilder.SetValues = this.UpdateBuilder.SetValues;
if (this.RemoveCacheFunc != null)
{
asyncUpdateable.RemoveDataCache();
}
return asyncUpdateable;
}

View File

@@ -46,7 +46,7 @@ namespace SqlSugar
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
return string.Format(" (TIMESTAMPDIFF(day,{0},{1})=0) ", parameter.MemberName, parameter2.MemberName); ;
return string.Format(" (TIMESTAMPDIFF(day,date({0}),date({1}))=0) ", parameter.MemberName, parameter2.MemberName); ;
}
public override string DateIsSameByType(MethodCallExpressionModel model)

View File

@@ -63,6 +63,36 @@ namespace SqlSugar
this.OrderByValue = oldOrderValue;
return result;
}
private string ToCountSqlString()
{
base.AppendFilter();
string oldOrderValue = this.OrderByValue;
string result = null;
sql = new StringBuilder();
sql.AppendFormat(SqlTemplate, "Count(*)", GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString);
if (IsCount) { return sql.ToString(); }
if (Skip != null && Take == null)
{
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString, Skip.ObjToInt(), long.MaxValue);
}
else if (Skip == null && Take != null)
{
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt());
}
else if (Skip != null && Take != null)
{
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take);
}
else
{
result = sql.ToString();
}
this.OrderByValue = oldOrderValue;
return result;
}
public override string ToCountSql(string sql)
{
if (this.GroupByValue.HasValue())
@@ -71,7 +101,7 @@ namespace SqlSugar
}
else
{
return Regex.Replace(sql, "^SELECT .+? FROM ", "SELECT COUNT(*) FROM ");
return ToCountSqlString();
}
}
#endregion