Update Core

This commit is contained in:
sunkaixuan
2019-05-21 13:17:29 +08:00
parent 8ce3e1de4b
commit 281d6c7d81
3 changed files with 35 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ namespace SqlSugar
foreach (var columnInfo in columnInfos)
{
string fileName = columnInfo.DbColumnName ?? columnInfo.PropertyName;
if (columnInfo.IsIgnore)
if (columnInfo.IsIgnore&& !this.ReaderKeys.Any(it=>it.Equals(fileName,StringComparison.CurrentCultureIgnoreCase)))
{
continue;
}

View File

@@ -22,7 +22,7 @@ namespace SqlSugar
public Result Get<Result>(Func<List<T>, Result> action)
{
GetIndex++;
string key = "Get" + GetIndex;
string key = "Get" +typeof(Result)+action.GetHashCode()+action.Method.Name;
if (caches.ContainsKey(key))
{
return (Result)caches[key];

View File

@@ -146,7 +146,7 @@ namespace SqlSugar
{
get
{
return "exec sp_rename '{0}.{1}','{2}','column';";
return "alter table {0} change column {1} {2}";
}
}
#endregion
@@ -366,6 +366,38 @@ namespace SqlSugar
return dataSize;
}
public override bool RenameColumn(string tableName, string oldColumnName, string newColumnName)
{
var columns=GetColumnInfosByTableName(tableName).Where(it=>it.DbColumnName.Equals(oldColumnName,StringComparison.CurrentCultureIgnoreCase));
if (columns != null && columns.Any())
{
var column = columns.First();
var appendSql = " " + column.DataType;
if (column.Length > 0 && column.Scale == 0)
{
appendSql += string.Format("({0}) ", column.Length);
}
else if (column.Scale > 0 && column.Length > 0)
{
appendSql += string.Format("({0},{1}) ", column.Length, column.Scale);
}
else
{
appendSql += column.IsNullable ? " NULL" : "NOT NULL";
}
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
oldColumnName = this.SqlBuilder.GetTranslationColumnName(oldColumnName);
newColumnName = this.SqlBuilder.GetTranslationColumnName(newColumnName);
string sql = string.Format(this.RenameColumnSql, tableName, oldColumnName, newColumnName+appendSql);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
else
{
return false;
}
}
public override bool IsAnyConstraint(string constraintName)
{
throw new NotSupportedException("MySql IsAnyConstraint NotSupportedException");