Update Core

This commit is contained in:
sunkaixuan
2018-12-03 00:35:00 +08:00
parent cd6c70001d
commit 8443581bac
5 changed files with 38 additions and 18 deletions

View File

@@ -484,8 +484,21 @@ namespace SqlSugar
} }
result.Add(item); result.Add(item);
} }
return result;
} }
return result; else {
DiffLogTableInfo diffTable = new DiffLogTableInfo();
diffTable.TableName = this.EntityInfo.DbTableName;
diffTable.TableDescription = this.EntityInfo.TableDescription;
diffTable.Columns = this.EntityInfo.Columns.Where(it => it.IsIgnore == false).Select(it => new DiffLogColumnInfo()
{
ColumnDescription = it.ColumnDescription,
ColumnName = it.DbColumnName,
Value = it.PropertyInfo.GetValue(this.InsertObjs.Last(), null)
}).ToList();
return new List<DiffLogTableInfo>() { diffTable };
}
} }
#endregion #endregion
} }

View File

@@ -39,8 +39,7 @@ namespace SqlSugar
{ {
return 150; return 150;
} }
else if (this.Context is OracleExpressionContext) else if (this.Context is OracleExpressionContext) {
{
return 401; return 401;
} }
@@ -60,11 +59,7 @@ namespace SqlSugar
} }
else if (this.Context is OracleExpressionContext) else if (this.Context is OracleExpressionContext)
{ {
return (HasWhere ? "AND" : "WHERE") + " ROWNUM=1"; return (HasWhere?"AND":"WHERE")+ " ROWNUM=1";
}
else if (this.Context is PostgreSQLExpressionContext)
{
return "limit 1";
} }
else else
{ {

View File

@@ -257,19 +257,19 @@ namespace SqlSugar
} }
return true; return true;
} }
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName,bool isCache=true) public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
{ {
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey); cacheKey = GetCacheKey(cacheKey);
if (!isCache) if (!isCache)
return GetColumnInfosByTableName(tableName); return GetColumnInfosByTableName(tableName);
else else
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() => () =>
{ {
return GetColumnInfosByTableName(tableName); return GetColumnInfosByTableName(tableName);
}); });
} }
private List<DbColumnInfo> GetColumnInfosByTableName(string tableName) private List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
@@ -330,7 +330,7 @@ namespace SqlSugar
string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME"; string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME";
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false; this.Context.Ado.IsEnableLogEvent = false;
var pks = this.Context.Ado.SqlQuery<string>(sql,new { tableName=tableName.ToUpper() }); var pks = this.Context.Ado.SqlQuery<string>(sql, new { tableName = tableName.ToUpper() });
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks; return pks;
}); });
@@ -350,7 +350,7 @@ namespace SqlSugar
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks; return pks;
}); });
return comments.HasValue() ? comments.First(it=>it.DbColumnName.Equals(filedName,StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : ""; return comments.HasValue() ? comments.First(it => it.DbColumnName.Equals(filedName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : "";
} }
@@ -364,6 +364,10 @@ namespace SqlSugar
{ {
item.Length = 50; item.Length = 50;
} }
if (item.DataType == "varchar" && item.Length == 0)
{
item.Length = 50;
}
} }
} }
string sql = GetCreateTableSql(tableName, columns); string sql = GetCreateTableSql(tableName, columns);

View File

@@ -80,7 +80,7 @@ namespace SqlSugar
{ {
return this.Context.Insertable(insertObjs).ExecuteCommand() > 0; return this.Context.Insertable(insertObjs).ExecuteCommand() > 0;
} }
public bool InsertRange<T>(List<T>[] insertObjs) where T : class, new() public bool InsertRange<T>(List<T> insertObjs) where T : class, new()
{ {
return this.Context.Insertable(insertObjs).ExecuteCommand() > 0; return this.Context.Insertable(insertObjs).ExecuteCommand() > 0;
} }
@@ -92,6 +92,10 @@ namespace SqlSugar
{ {
return this.Context.Updateable(updateObjs).ExecuteCommand() > 0; return this.Context.Updateable(updateObjs).ExecuteCommand() > 0;
} }
public bool UpdateRange<T>(List<T> updateObjs) where T : class, new()
{
return this.Context.Updateable(updateObjs).ExecuteCommand() > 0;
}
public bool Update<T>(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression) where T : class, new() public bool Update<T>(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression) where T : class, new()
{ {
return this.Context.Updateable<T>().UpdateColumns(columns).Where(whereExpression).ExecuteCommand() > 0; return this.Context.Updateable<T>().UpdateColumns(columns).Where(whereExpression).ExecuteCommand() > 0;
@@ -193,7 +197,7 @@ namespace SqlSugar
{ {
return this.Context.Insertable(insertObjs).ExecuteCommand() > 0; return this.Context.Insertable(insertObjs).ExecuteCommand() > 0;
} }
public bool InsertRange(List<T>[] insertObjs) public bool InsertRange(List<T> insertObjs)
{ {
return this.Context.Insertable(insertObjs).ExecuteCommand() > 0; return this.Context.Insertable(insertObjs).ExecuteCommand() > 0;
} }
@@ -205,6 +209,10 @@ namespace SqlSugar
{ {
return this.Context.Updateable(updateObjs).ExecuteCommand() > 0; return this.Context.Updateable(updateObjs).ExecuteCommand() > 0;
} }
public bool UpdateRange(List<T> updateObjs)
{
return this.Context.Updateable(updateObjs).ExecuteCommand() > 0;
}
public bool Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression) public bool Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
{ {
return this.Context.Updateable<T>().UpdateColumns(columns).Where(whereExpression).ExecuteCommand() > 0; return this.Context.Updateable<T>().UpdateColumns(columns).Where(whereExpression).ExecuteCommand() > 0;