Browse Source

Update Core

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
e1578bb3a0
  1. 6
      Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Config.cs
  2. 11
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  3. 11
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  4. 19
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  5. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs
  6. 22
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  7. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/CacheScheme/CacheKeyBuider.cs
  8. 8
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs
  9. 33
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs
  10. 1
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs
  11. 26
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs
  12. 34
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  13. 62
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubAndIF.cs
  14. 10
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/SubResolve.cs
  15. 1
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/SubTools.cs
  16. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IUpdateable.cs
  17. 7
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleBuilder.cs
  18. 10
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs
  19. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarClient.cs
  20. 1
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Utilities/UtilConstants.cs
  21. 16
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Utilities/UtilMethods.cs
  22. BIN
      Src/Asp.NetCore2/SqlSeverTest/SqliteTest/DataBase/SqlSugar4xTest.sqlite

6
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Config.cs

@ -8,8 +8,8 @@ namespace OrmTest
{
public class Config
{
public static string ConnectionString = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
public static string ConnectionString2 = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
public static string ConnectionString3 = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
public static string ConnectionString = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=jhl52771;USER ID=postgres";
public static string ConnectionString2 = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=jhl52771;USER ID=postgres";
public static string ConnectionString3 = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=jhl52771;USER ID=postgres";
}
}

11
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

@ -21,6 +21,7 @@ namespace SqlSugar
public bool IsEnableDiffLogEvent { get; set; }
public DiffLogModel diffModel { get; set; }
public List<string> tempPrimaryKeys { get; set; }
private Action RemoveCacheFunc { get; set; }
public EntityInfo EntityInfo
{
get
@ -213,8 +214,11 @@ namespace SqlSugar
public IDeleteable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
this.RemoveCacheFunc = () =>
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
};
return this;
}
@ -398,6 +402,9 @@ namespace SqlSugar
if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel);
}
if (this.RemoveCacheFunc != null) {
this.RemoveCacheFunc();
}
}
private void Before(string sql)

11
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -29,6 +29,7 @@ namespace SqlSugar
public bool IsAs { get; set; }
public bool IsEnableDiffLogEvent { get; set; }
public DiffLogModel diffModel { get; set; }
private Action RemoveCacheFunc { get; set; }
#region Core
@ -214,8 +215,11 @@ namespace SqlSugar
public IInsertable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
this.RemoveCacheFunc = () =>
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
};
return this;
}
public IInsertable<T> EnableDiffLogEvent(object businessData = null)
@ -436,6 +440,9 @@ namespace SqlSugar
if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel);
}
if (this.RemoveCacheFunc != null) {
this.RemoveCacheFunc();
}
}
private void Before(string sql)
{

19
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -484,7 +484,7 @@ namespace SqlSugar
}
public virtual ISugarQueryable<T> MergeTable()
{
Check.Exception(this.MapperAction != null, "'Mapper’ needs to be written after ‘MergeTable’ ");
Check.Exception(this.MapperAction != null||this.MapperActionWithCache!=null, "'Mapper’ needs to be written after ‘MergeTable’ ");
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Queryable.Select Method .");
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0 || this.QueryBuilder.OrderByValue.HasValue(), "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
ToSqlBefore();
@ -1006,9 +1006,19 @@ namespace SqlSugar
{
QueryBuilder.CheckExpression(expression, "OrderBy");
var isSingle = QueryBuilder.IsSingle();
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
OrderBy(lamResult.GetResultString() + UtilConstants.Space + type.ToString().ToUpper());
return this;
if ((expression as LambdaExpression).Body is NewExpression)
{
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.ArraySingle : ResolveExpressType.ArrayMultiple);
var items = lamResult.GetResultString().Split(',').Where(it => it.HasValue()).Select(it=> it + UtilConstants.Space + type.ToString().ToUpper()).ToList();
OrderBy(string.Join(",",items));
return this;
}
else
{
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
OrderBy(lamResult.GetResultString() + UtilConstants.Space + type.ToString().ToUpper());
return this;
}
}
protected ISugarQueryable<T> _GroupBy(Expression expression)
{
@ -1313,6 +1323,7 @@ namespace SqlSugar
asyncQueryableBuilder.PartitionByValue = this.QueryBuilder.PartitionByValue;
asyncQueryableBuilder.JoinExpression = this.QueryBuilder.JoinExpression;
asyncQueryableBuilder.WhereIndex = this.QueryBuilder.WhereIndex;
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
}
#endregion

4
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs

@ -98,11 +98,11 @@ namespace SqlSugar
}
public virtual string GetUnionAllSql(List<string> sqlList)
{
return string.Join("UNION ALL \r\n", sqlList);
return string.Join(" UNION ALL \r\n", sqlList);
}
public virtual string GetUnionSql(List<string> sqlList)
{
return string.Join("UNION \r\n", sqlList);
return string.Join(" UNION \r\n", sqlList);
}
public virtual void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex)
{

22
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

@ -17,18 +17,21 @@ namespace SqlSugar
public UpdateBuilder UpdateBuilder { get; set; }
public IAdo Ado { get { return Context.Ado; } }
public T[] UpdateObjs { get; set; }
public bool UpdateParameterIsNull { get; set; }
public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } }
public bool IsMappingColumns { get { return this.Context.MappingColumns != null && this.Context.MappingColumns.Any(); } }
public bool IsSingle { get { return this.UpdateObjs.Length == 1; } }
public List<MappingColumn> MappingColumnList { get; set; }
private List<string> IgnoreColumnNameList { get; set; }
private List<string> WhereColumnList { get; set; }
private bool IsWhereColumns { get; set; }
private bool IsOffIdentity { get; set; }
private bool IsVersionValidation { get; set; }
public MappingTableList OldMappingTableList { get; set; }
public bool IsAs { get; set; }
public bool IsEnableDiffLogEvent { get; set; }
public DiffLogModel diffModel { get; set; }
private Action RemoveCacheFunc { get; set; }
public virtual int ExecuteCommand()
{
@ -152,6 +155,8 @@ namespace SqlSugar
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns)
{
this.IsWhereColumns = true;
Check.Exception(UpdateParameterIsNull==true, "Updateable<T>().Updateable is error,Use Updateable(obj).WhereColumns");
var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
foreach (var item in whereColumns)
@ -314,8 +319,11 @@ namespace SqlSugar
public IUpdateable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
this.RemoveCacheFunc = () =>
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
};
return this;
}
@ -392,6 +400,13 @@ namespace SqlSugar
private void PreToSql()
{
UpdateBuilder.PrimaryKeys = GetPrimaryKeys();
if (this.IsWhereColumns) {
foreach (var pkName in UpdateBuilder.PrimaryKeys)
{
var isContains=this.UpdateBuilder.DbColumnInfoList.Select(it => it.DbColumnName.ToLower()).Contains(pkName.ToLower());
Check.Exception(isContains == false, "Use UpdateColumns().WhereColumn() ,UpdateColumns need {0}", pkName);
}
}
#region IgnoreColumns
if (this.Context.IgnoreColumns != null && this.Context.IgnoreColumns.Any())
{
@ -586,6 +601,9 @@ namespace SqlSugar
if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel);
}
if (this.RemoveCacheFunc != null) {
this.RemoveCacheFunc();
}
}
private void Before(string sql)

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/CacheScheme/CacheKeyBuider.cs

@ -28,7 +28,7 @@ namespace SqlSugar
result.IdentificationList.Add(queryBuilder.Take.ObjToString());
result.IdentificationList.Add(queryBuilder.Skip.ObjToString());
result.IdentificationList.Add(queryBuilder.IsCount.ObjToString());
result.IdentificationList.Add(queryBuilder.GetSelectValue.ObjToString().Length.ObjToString());
result.IdentificationList.Add(UtilMethods.GetMD5(queryBuilder.GetSelectValue.ObjToString()));
if (queryBuilder.Parameters.HasValue())
{
foreach (var item in queryBuilder.Parameters)

8
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs

@ -25,14 +25,14 @@ namespace SqlSugar
this.ParameterName = name;
SettingDataType(type);
}
public SugarParameter(string name, object value, Type type,ParameterDirection direction)
public SugarParameter(string name, object value, Type type, ParameterDirection direction)
{
this.Value = value;
this.ParameterName = name;
this.Direction = direction;
SettingDataType(type);
}
public SugarParameter(string name, object value, Type type, ParameterDirection direction,int size)
public SugarParameter(string name, object value, Type type, ParameterDirection direction, int size)
{
this.Value = value;
this.ParameterName = name;
@ -95,6 +95,10 @@ namespace SqlSugar
{
this.DbType = System.Data.DbType.DateTimeOffset;
}
else if (type == UtilConstants.TimeSpanType)
{
this.Value = this.Value.ToString();
}
}
public SugarParameter(string name, object value, bool isOutput)

33
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

@ -445,5 +445,38 @@ namespace SqlSugar
Check.ThrowNotSupportedException(item.GetType().Name);
}
}
protected static Dictionary<string, string> MethodMapping = new Dictionary<string, string>() {
{ "ToString","ToString"},
{ "ToInt32","ToInt32"},
{ "ToInt16","ToInt32"},
{ "ToInt64","ToInt64"},
{ "ToDecimal","ToDecimal"},
{ "ToDateTime","ToDate"},
{ "ToBoolean","ToBool"},
{ "ToDouble","ToDouble"},
{ "Length","Length"},
{ "Replace","Replace"},
{ "Contains","Contains"},
{ "ContainsArray","ContainsArray"},
{ "EndsWith","EndsWith"},
{ "StartsWith","StartsWith"},
{ "HasValue","HasValue"},
{ "Trim","Trim"},
{ "Equals","Equals"},
{ "ToLower","ToLower"},
{ "ToUpper","ToUpper"},
{ "Substring","Substring"},
{ "DateAdd","DateAdd"}
};
protected static Dictionary<string, DateType> MethodTimeMapping = new Dictionary<string, DateType>() {
{ "AddYears",DateType.Year},
{ "AddMonths",DateType.Month},
{ "AddDays",DateType.Day},
{ "AddHours",DateType.Hour},
{ "AddMinutes",DateType.Minute},
{ "AddSeconds",DateType.Second},
{ "AddMilliseconds",DateType.Millisecond}
};
}
}

1
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -60,6 +60,7 @@ namespace SqlSugar
string fieldName = string.Empty;
switch (parameter.Context.ResolveType)
{
case ResolveExpressType.Update:
case ResolveExpressType.SelectSingle:
fieldName = GetSingleName(parameter, expression, isLeft);
if (isSetTempData)

26
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

@ -61,7 +61,17 @@ namespace SqlSugar
{
if (item is UnaryExpression)
item = (item as UnaryExpression).Operand;
MethodCall(parameter, memberName, item);
var callMethod = item as MethodCallExpression;
if (MethodTimeMapping.Any(it => it.Key == callMethod.Method.Name) || MethodMapping.Any(it=>it.Key==callMethod.Method.Name)||IsExtMethod(callMethod.Method.Name)||IsSubMethod(callMethod)|| callMethod.Method.DeclaringType.FullName.StartsWith(UtilConstants.AssemblyName+UtilConstants.Dot))
{
MethodCall(parameter, memberName, item);
}
else
{
var paramterValue = ExpressionTool.DynamicInvoke(item);
string parameterName = AppendParameter(paramterValue);
this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
}
}
else if (IsConst(item))
{
@ -147,5 +157,19 @@ namespace SqlSugar
{
return SubTools.SubItemsConst.Any(it =>express.Object != null && express.Object.Type.Name == "Subqueryable`1");
}
private bool IsExtMethod(string methodName)
{
if (this.Context.SqlFuncServices == null) return false;
return this.Context.SqlFuncServices.Select(it => it.UniqueMethodName).Contains(methodName);
}
private bool CheckMethod(MethodCallExpression expression)
{
if (IsExtMethod(expression.Method.Name))
return true;
if (expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName)
return false;
else
return true;
}
}
}

34
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -513,40 +513,6 @@ namespace SqlSugar
return null;
}
private static Dictionary<string, string> MethodMapping = new Dictionary<string, string>() {
{ "ToString","ToString"},
{ "ToInt32","ToInt32"},
{ "ToInt16","ToInt32"},
{ "ToInt64","ToInt64"},
{ "ToDecimal","ToDecimal"},
{ "ToDateTime","ToDate"},
{ "ToBoolean","ToBool"},
{ "ToDouble","ToDouble"},
{ "Length","Length"},
{ "Replace","Replace"},
{ "Contains","Contains"},
{ "ContainsArray","ContainsArray"},
{ "EndsWith","EndsWith"},
{ "StartsWith","StartsWith"},
{ "HasValue","HasValue"},
{ "Trim","Trim"},
{ "Equals","Equals"},
{ "ToLower","ToLower"},
{ "ToUpper","ToUpper"},
{ "Substring","Substring"},
{ "DateAdd","DateAdd"}
};
private static Dictionary<string, DateType> MethodTimeMapping = new Dictionary<string, DateType>() {
{ "AddYears",DateType.Year},
{ "AddMonths",DateType.Month},
{ "AddDays",DateType.Day},
{ "AddHours",DateType.Hour},
{ "AddMinutes",DateType.Minute},
{ "AddSeconds",DateType.Second},
{ "AddMilliseconds",DateType.Millisecond}
};
private bool IsContainsArray(MethodCallExpression express, string methodName, bool isValidNativeMethod)
{
return !isValidNativeMethod && express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains";

62
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubAndIF.cs

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace SqlSugar
{
public class SubAndIF : ISubOperation
{
public bool HasWhere
{
get; set;
}
public string Name
{
get { return "WhereIF"; }
}
public Expression Expression
{
get; set;
}
public int Sort
{
get
{
return 400;
}
}
public ExpressionContext Context
{
get; set;
}
public string GetValue(Expression expression)
{
var exp = expression as MethodCallExpression;
object value = null;
try
{
value = ExpressionTool.DynamicInvoke(exp.Arguments[0]);
}
catch
{
Check.Exception(true, ErrorMessage.WhereIFCheck,exp.Arguments[0].ToString());
}
var isWhere= Convert.ToBoolean(value);
if (!Convert.ToBoolean(isWhere)) {
return "";
}
var argExp = exp.Arguments[1];
var result = "AND " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); ;
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;
}
}
}

10
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/SubResolve.cs

@ -87,6 +87,16 @@ namespace SqlSugar
{
item = items.First(s => s is SubAnd);
}
if (item is SubWhereIF && hasWhere == false)
{
hasWhere = true;
}
else if (item is SubWhereIF)
{
item = items.First(s => s is SubAndIF);
}
item.Context = this.context;
item.Expression = exp;
return item;

1
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/SubTools.cs

@ -17,6 +17,7 @@ namespace SqlSugar
new SubWhere(){ Context=Context },
new SubWhereIF(){ Context=Context },
new SubAnd(){ Context=Context },
new SubAndIF(){ Context=Context },
new SubAny(){ Context=Context },
new SubNotAny(){ Context=Context },
new SubBegin(){ Context=Context },

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IUpdateable.cs

@ -10,6 +10,8 @@ namespace SqlSugar
public interface IUpdateable<T> where T : class, new()
{
UpdateBuilder UpdateBuilder { get; set; }
bool UpdateParameterIsNull { get; set; }
int ExecuteCommand();
bool ExecuteCommandHasChange();
Task<int> ExecuteCommandAsync();

7
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleBuilder.cs

@ -34,8 +34,11 @@ namespace SqlSugar
public override string SqlTranslationRight { get { return "\""; } }
public override string GetTranslationTableName(string name)
{
var result= base.GetTranslationTableName(name);
return result.ToUpper();
var result = base.GetTranslationTableName(name);
if (result.Contains("(") && result.Contains(")"))
return result;
else
return result.ToUpper();
}
public override string GetTranslationColumnName(string entityName, string propertyName)
{

10
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs

@ -280,5 +280,15 @@ namespace SqlSugar
}
return true;
}
public override bool RenameColumn(string tableName, string oldColumnName, string newColumnName)
{
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
oldColumnName = this.SqlBuilder.GetTranslationColumnName(oldColumnName);
newColumnName = this.SqlBuilder.GetNoTranslationColumnName(newColumnName);
string sql = string.Format(this.RenameColumnSql, tableName, oldColumnName, newColumnName);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
}
}

4
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarClient.cs

@ -532,7 +532,9 @@ namespace SqlSugar
}
public virtual IUpdateable<T> Updateable<T>() where T : class, new()
{
return this.Context.Updateable(new T[] { new T() });
var result= this.Context.Updateable(new T[] { new T() });
result.UpdateParameterIsNull=true;
return result;
}
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
{

1
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Utilities/UtilConstants.cs

@ -29,6 +29,7 @@ namespace SqlSugar
internal static Type StringType = typeof(string);
internal static Type DateType = typeof(DateTime);
internal static Type DateTimeOffsetType = typeof(DateTimeOffset);
internal static Type TimeSpanType = typeof(TimeSpan);
internal static Type ByteArrayType = typeof(byte[]);
internal static Type ModelType= typeof(ModelContext);
internal static Type DynamicType = typeof(ExpandoObject);

16
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Utilities/UtilMethods.cs

@ -4,6 +4,7 @@ using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
@ -114,5 +115,20 @@ namespace SqlSugar
return Convert.ToInt64(string.Join("", bytes).PadRight(20, '0'));
}
internal static string GetMD5(string myString)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] fromData = System.Text.Encoding.Unicode.GetBytes(myString);
byte[] targetData = md5.ComputeHash(fromData);
string byte2String = null;
for (int i = 0; i < targetData.Length; i++)
{
byte2String += targetData[i].ToString("x");
}
return byte2String;
}
}
}

BIN
Src/Asp.NetCore2/SqlSeverTest/SqliteTest/DataBase/SqlSugar4xTest.sqlite

Binary file not shown.
Loading…
Cancel
Save