mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-29 10:49:36 +08:00
Update core
This commit is contained in:
parent
2e6c9357dd
commit
0e9cbefd86
@ -442,7 +442,14 @@ namespace SqlSugar
|
||||
DeleteBuilder.TableWithString = lockString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual string ToSqlString()
|
||||
{
|
||||
var sqlObj = this.ToSql();
|
||||
var result = sqlObj.Key;
|
||||
if (result == null) return null;
|
||||
result = UtilMethods.GetSqlString(this.Context.CurrentConnectionConfig, sqlObj, result);
|
||||
return result;
|
||||
}
|
||||
public KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
DeleteBuilder.EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||
|
@ -53,6 +53,14 @@ namespace SqlSugar
|
||||
After(sql, null);
|
||||
return result;
|
||||
}
|
||||
public virtual string ToSqlString()
|
||||
{
|
||||
var sqlObj = this.ToSql();
|
||||
var result = sqlObj.Key;
|
||||
if (result == null) return null;
|
||||
result = UtilMethods.GetSqlString(this.Context.CurrentConnectionConfig, sqlObj, result);
|
||||
return result;
|
||||
}
|
||||
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
InsertBuilder.IsReturnIdentity = true;
|
||||
|
@ -1932,35 +1932,16 @@ namespace SqlSugar
|
||||
totalPage = (totalNumber + pageSize - 1) / pageSize;
|
||||
return result;
|
||||
}
|
||||
public virtual string ToSqlString()
|
||||
public virtual string ToSqlString()
|
||||
{
|
||||
var sqlObj = this.Clone().ToSql();
|
||||
var result = sqlObj.Key;
|
||||
if (result == null) return null;
|
||||
if (sqlObj.Value != null)
|
||||
{
|
||||
foreach (var item in sqlObj.Value.OrderByDescending(it=>it.ParameterName.Length))
|
||||
{
|
||||
if (item.Value == null || item.Value == DBNull.Value)
|
||||
{
|
||||
result = result.Replace(item.ParameterName, "null");
|
||||
}
|
||||
else if (UtilMethods.IsNumber(item.Value.GetType().Name))
|
||||
{
|
||||
result = result.Replace(item.ParameterName, item.Value.ObjToString());
|
||||
}
|
||||
else if(this.Context.CurrentConnectionConfig.MoreSettings?.DisableNvarchar==true||item.DbType==System.Data.DbType.AnsiString||this.Context.CurrentConnectionConfig.DbType==DbType.Sqlite)
|
||||
{
|
||||
result = result.Replace(item.ParameterName, $"'{item.Value.ObjToString()}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result.Replace(item.ParameterName, $"N'{item.Value.ObjToString()}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
result = UtilMethods.GetSqlString(this.Context.CurrentConnectionConfig,sqlObj, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
if (!QueryBuilder.IsClone)
|
||||
|
@ -38,6 +38,14 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Core
|
||||
public virtual string ToSqlString()
|
||||
{
|
||||
var sqlObj = this.ToSql();
|
||||
var result = sqlObj.Key;
|
||||
if (result == null) return null;
|
||||
result = UtilMethods.GetSqlString(this.Context.CurrentConnectionConfig, sqlObj, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ namespace SqlSugar
|
||||
IDeleteable<T> RemoveDataCache();
|
||||
IDeleteable<T> RemoveDataCache(string likeString);
|
||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||
string ToSqlString();
|
||||
IDeleteable<T> EnableQueryFilter();
|
||||
SplitTableDeleteProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc);
|
||||
SplitTableDeleteByObjectProvider<T> SplitTable();
|
||||
|
@ -93,6 +93,7 @@ namespace SqlSugar
|
||||
IUpdateable<T> RemoveDataCache(string likeString);
|
||||
IUpdateable<T> CallEntityMethod(Expression<Action<T>> method);
|
||||
KeyValuePair<string,List<SugarParameter>> ToSql();
|
||||
string ToSqlString();
|
||||
void AddQueue();
|
||||
SplitTableUpdateProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc);
|
||||
SplitTableUpdateByObjectProvider<T> SplitTable();
|
||||
|
@ -42,6 +42,7 @@ namespace SqlSugar
|
||||
IInsertable<T> RemoveDataCache();
|
||||
IInsertable<T> RemoveDataCache(string likeString);
|
||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||
string ToSqlString();
|
||||
SqlServerBlukCopy UseSqlServer();
|
||||
MySqlBlukCopy<T> UseMySql();
|
||||
OracleBlukCopy UseOracle();
|
||||
|
@ -730,5 +730,33 @@ namespace SqlSugar
|
||||
string FirstDay = datetime.AddDays(daydiff).ToString("yyyy-MM-dd");
|
||||
return Convert.ToDateTime(FirstDay);
|
||||
}
|
||||
|
||||
public static string GetSqlString(ConnectionConfig connectionConfig,KeyValuePair<string, List<SugarParameter>> sqlObj, string result)
|
||||
{
|
||||
if (sqlObj.Value != null)
|
||||
{
|
||||
foreach (var item in sqlObj.Value.OrderByDescending(it => it.ParameterName.Length))
|
||||
{
|
||||
if (item.Value == null || item.Value == DBNull.Value)
|
||||
{
|
||||
result = result.Replace(item.ParameterName, "null");
|
||||
}
|
||||
else if (UtilMethods.IsNumber(item.Value.GetType().Name))
|
||||
{
|
||||
result = result.Replace(item.ParameterName, item.Value.ObjToString());
|
||||
}
|
||||
else if (connectionConfig.MoreSettings?.DisableNvarchar == true || item.DbType == System.Data.DbType.AnsiString || connectionConfig.DbType == DbType.Sqlite)
|
||||
{
|
||||
result = result.Replace(item.ParameterName, $"'{item.Value.ObjToString()}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result.Replace(item.ParameterName, $"N'{item.Value.ObjToString()}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user