Update Core

This commit is contained in:
sunkaixuan
2019-01-01 23:32:21 +08:00
parent c655e984d3
commit e1578bb3a0
22 changed files with 234 additions and 56 deletions

View File

@@ -8,8 +8,8 @@ namespace OrmTest
{ {
public class Config public class Config
{ {
public static string ConnectionString = "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=haosql;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=haosql;USER ID=postgres"; public static string ConnectionString3 = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=jhl52771;USER ID=postgres";
} }
} }

View File

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

View File

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

View File

@@ -484,7 +484,7 @@ namespace SqlSugar
} }
public virtual ISugarQueryable<T> MergeTable() 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.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 "); Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0 || this.QueryBuilder.OrderByValue.HasValue(), "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
ToSqlBefore(); ToSqlBefore();
@@ -1006,10 +1006,20 @@ namespace SqlSugar
{ {
QueryBuilder.CheckExpression(expression, "OrderBy"); QueryBuilder.CheckExpression(expression, "OrderBy");
var isSingle = QueryBuilder.IsSingle(); var isSingle = QueryBuilder.IsSingle();
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); var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
OrderBy(lamResult.GetResultString() + UtilConstants.Space + type.ToString().ToUpper()); OrderBy(lamResult.GetResultString() + UtilConstants.Space + type.ToString().ToUpper());
return this; return this;
} }
}
protected ISugarQueryable<T> _GroupBy(Expression expression) protected ISugarQueryable<T> _GroupBy(Expression expression)
{ {
QueryBuilder.CheckExpression(expression, "GroupBy"); QueryBuilder.CheckExpression(expression, "GroupBy");
@@ -1313,6 +1323,7 @@ namespace SqlSugar
asyncQueryableBuilder.PartitionByValue = this.QueryBuilder.PartitionByValue; asyncQueryableBuilder.PartitionByValue = this.QueryBuilder.PartitionByValue;
asyncQueryableBuilder.JoinExpression = this.QueryBuilder.JoinExpression; asyncQueryableBuilder.JoinExpression = this.QueryBuilder.JoinExpression;
asyncQueryableBuilder.WhereIndex = this.QueryBuilder.WhereIndex; asyncQueryableBuilder.WhereIndex = this.QueryBuilder.WhereIndex;
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
} }
#endregion #endregion

View File

@@ -17,18 +17,21 @@ namespace SqlSugar
public UpdateBuilder UpdateBuilder { get; 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 UpdateParameterIsNull { 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(); } }
public bool IsMappingColumns { get { return this.Context.MappingColumns != null && this.Context.MappingColumns.Any(); } } public bool IsMappingColumns { get { return this.Context.MappingColumns != null && this.Context.MappingColumns.Any(); } }
public bool IsSingle { get { return this.UpdateObjs.Length == 1; } } public bool IsSingle { get { return this.UpdateObjs.Length == 1; } }
public List<MappingColumn> MappingColumnList { get; set; } public List<MappingColumn> MappingColumnList { get; set; }
private List<string> IgnoreColumnNameList { get; set; } private List<string> IgnoreColumnNameList { get; set; }
private List<string> WhereColumnList { get; set; } private List<string> WhereColumnList { get; set; }
private bool IsWhereColumns { get; set; }
private bool IsOffIdentity { get; set; } private bool IsOffIdentity { get; set; }
private bool IsVersionValidation { get; set; } private bool IsVersionValidation { get; set; }
public MappingTableList OldMappingTableList { get; set; } public MappingTableList OldMappingTableList { get; set; }
public bool IsAs { get; set; } public bool IsAs { get; set; }
public bool IsEnableDiffLogEvent { get; set; } public bool IsEnableDiffLogEvent { get; set; }
public DiffLogModel diffModel { get; set; } public DiffLogModel diffModel { get; set; }
private Action RemoveCacheFunc { get; set; }
public virtual int ExecuteCommand() public virtual int ExecuteCommand()
{ {
@@ -152,6 +155,8 @@ namespace SqlSugar
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns) 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(); var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>(); if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
foreach (var item in whereColumns) foreach (var item in whereColumns)
@@ -313,9 +318,12 @@ namespace SqlSugar
} }
public IUpdateable<T> RemoveDataCache() public IUpdateable<T> RemoveDataCache()
{
this.RemoveCacheFunc = () =>
{ {
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService; var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>()); CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
};
return this; return this;
} }
@@ -392,6 +400,13 @@ namespace SqlSugar
private void PreToSql() private void PreToSql()
{ {
UpdateBuilder.PrimaryKeys = GetPrimaryKeys(); 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 #region IgnoreColumns
if (this.Context.IgnoreColumns != null && this.Context.IgnoreColumns.Any()) if (this.Context.IgnoreColumns != null && this.Context.IgnoreColumns.Any())
{ {
@@ -586,6 +601,9 @@ namespace SqlSugar
if (this.Context.Ado.DiffLogEvent != null) if (this.Context.Ado.DiffLogEvent != null)
this.Context.Ado.DiffLogEvent(diffModel); this.Context.Ado.DiffLogEvent(diffModel);
} }
if (this.RemoveCacheFunc != null) {
this.RemoveCacheFunc();
}
} }
private void Before(string sql) private void Before(string sql)

View File

@@ -28,7 +28,7 @@ namespace SqlSugar
result.IdentificationList.Add(queryBuilder.Take.ObjToString()); result.IdentificationList.Add(queryBuilder.Take.ObjToString());
result.IdentificationList.Add(queryBuilder.Skip.ObjToString()); result.IdentificationList.Add(queryBuilder.Skip.ObjToString());
result.IdentificationList.Add(queryBuilder.IsCount.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()) if (queryBuilder.Parameters.HasValue())
{ {
foreach (var item in queryBuilder.Parameters) foreach (var item in queryBuilder.Parameters)

View File

@@ -95,6 +95,10 @@ namespace SqlSugar
{ {
this.DbType = System.Data.DbType.DateTimeOffset; this.DbType = System.Data.DbType.DateTimeOffset;
} }
else if (type == UtilConstants.TimeSpanType)
{
this.Value = this.Value.ToString();
}
} }
public SugarParameter(string name, object value, bool isOutput) public SugarParameter(string name, object value, bool isOutput)

View File

@@ -445,5 +445,38 @@ namespace SqlSugar
Check.ThrowNotSupportedException(item.GetType().Name); 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}
};
} }
} }

View File

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

View File

@@ -61,8 +61,18 @@ namespace SqlSugar
{ {
if (item is UnaryExpression) if (item is UnaryExpression)
item = (item as UnaryExpression).Operand; item = (item as UnaryExpression).Operand;
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); 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)) else if (IsConst(item))
{ {
base.Expression = item; base.Expression = item;
@@ -147,5 +157,19 @@ namespace SqlSugar
{ {
return SubTools.SubItemsConst.Any(it =>express.Object != null && express.Object.Type.Name == "Subqueryable`1"); 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;
}
} }
} }

View File

@@ -513,40 +513,6 @@ namespace SqlSugar
return null; 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) private bool IsContainsArray(MethodCallExpression express, string methodName, bool isValidNativeMethod)
{ {
return !isValidNativeMethod && express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains"; return !isValidNativeMethod && express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains";

View File

@@ -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;
}
}
}

View File

@@ -87,6 +87,16 @@ namespace SqlSugar
{ {
item = items.First(s => s is SubAnd); 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.Context = this.context;
item.Expression = exp; item.Expression = exp;
return item; return item;

View File

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

View File

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

View File

@@ -35,6 +35,9 @@ namespace SqlSugar
public override string GetTranslationTableName(string name) public override string GetTranslationTableName(string name)
{ {
var result = base.GetTranslationTableName(name); var result = base.GetTranslationTableName(name);
if (result.Contains("(") && result.Contains(")"))
return result;
else
return result.ToUpper(); return result.ToUpper();
} }
public override string GetTranslationColumnName(string entityName, string propertyName) public override string GetTranslationColumnName(string entityName, string propertyName)

View File

@@ -280,5 +280,15 @@ namespace SqlSugar
} }
return true; 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;
}
} }
} }

View File

@@ -532,7 +532,9 @@ namespace SqlSugar
} }
public virtual IUpdateable<T> Updateable<T>() where T : class, new() 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() public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
{ {

View File

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

View File

@@ -4,6 +4,7 @@ using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -114,5 +115,20 @@ namespace SqlSugar
return Convert.ToInt64(string.Join("", bytes).PadRight(20, '0')); 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;
}
} }
} }