Browse Source

Update Core

pull/2/head
skx 4 years ago
parent
commit
f1bb1d36cf
  1. 8
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs
  2. 19
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  3. 92
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  4. 17
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs
  5. 63
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  6. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/ConnMoreSettings.cs
  7. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/ConnectionConfig.cs
  8. 91
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MapperExpressionResolve.cs
  9. 9
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs
  10. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  11. 13
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IQueryable.cs
  12. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/ISimpleClient.cs
  13. 23
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IUpdateable.cs
  14. 9
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/Insertable.cs
  15. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Dm/DmProvider.cs
  16. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/MySqlProvider.cs
  17. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs
  18. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs
  19. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/OracleProvider.cs
  20. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs
  21. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs
  22. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs
  23. 7
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/SqlServerProvider.cs
  24. 8
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SimpleClient.cs
  25. 5
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarClient.cs
  26. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Utilities/UtilConvert.cs
  27. 123
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Utilities/UtilExtensions.cs

8
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs

@ -306,13 +306,13 @@ namespace SqlSugar
}
public virtual bool CreateIndex(string tableName, string[] columnNames, bool isUnique=false)
{
string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames), isUnique ? "UNIQUE" : "");
string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix, isUnique ? "UNIQUE" : "");
this.Context.Ado.ExecuteCommand(sql);
return true;
}
public virtual bool CreateUniqueIndex(string tableName, string[] columnNames)
{
string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames)+"_Unique","UNIQUE" );
string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix + "_Unique","UNIQUE" );
this.Context.Ado.ExecuteCommand(sql);
return true;
}
@ -370,7 +370,7 @@ namespace SqlSugar
foreach (var item in groups)
{
var columnNames = indexColumns.Where(it => it.IndexGroupNameList.Any(i => i.Equals(item, StringComparison.CurrentCultureIgnoreCase))).Select(it=>it.DbColumnName).ToArray();
var indexName = string.Format("Index_{0}_{1}",entityInfo.DbTableName, string.Join("_", columnNames));
var indexName = string.Format("Index_{0}_{1}"+this.Context.CurrentConnectionConfig.IndexSuffix,entityInfo.DbTableName, string.Join("_", columnNames));
if (!IsAnyIndex(indexName))
{
CreateIndex(entityInfo.DbTableName, columnNames);
@ -386,7 +386,7 @@ namespace SqlSugar
foreach (var item in groups)
{
var columnNames = uIndexColumns.Where(it => it.UIndexGroupNameList.Any(i => i.Equals(item, StringComparison.CurrentCultureIgnoreCase))).Select(it => it.DbColumnName).ToArray();
var indexName = string.Format("Index_{0}_{1}_Unique", entityInfo.DbTableName, string.Join("_", columnNames));
var indexName = string.Format("Index_{0}_{1}_Unique" + this.Context.CurrentConnectionConfig.IndexSuffix, entityInfo.DbTableName, string.Join("_", columnNames));
if (!IsAnyIndex(indexName))
{
CreateUniqueIndex(entityInfo.DbTableName, columnNames);

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

@ -669,24 +669,5 @@ namespace SqlSugar
}
#endregion
#region Obsolete
[Obsolete]
public IInsertable<T> InsertColumns(Func<string, bool> insertColumMethod)
{
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => insertColumMethod(it.PropertyName)).ToList();
return this;
}
[Obsolete]
public IInsertable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod)
{
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumMethod(it.PropertyName)).ToList();
return this;
}
[Obsolete]
public IInsertable<T> Where(bool ignoreNullColumn, bool isOffIdentity = false)
{
return IgnoreColumns(ignoreNullColumn, isOffIdentity);
}
#endregion
}
}

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

@ -129,6 +129,12 @@ namespace SqlSugar
}
public virtual ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, List<TObject>>> mapperObject, Expression<Func<T, object>> mapperField)
{
Check.Exception(mapperObject.ReturnType.Name == "IList`1", "Mapper no support IList , Use List<T>");
if (CallContext.MapperExpression.Value == null)
{
CallContext.MapperExpression.Value = new List<MapperExpression>();
}
CallContext.MapperExpression.Value.Add(new MapperExpression() { SqlBuilder = SqlBuilder, QueryBuilder = this.QueryBuilder, Type = MapperExpressionType.oneToN, FillExpression = mapperObject, MappingField1Expression = mapperField,Context = this.Context });
return _Mapper<TObject>(mapperObject, mapperField);
}
public virtual ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, TObject>> mapperObject, Expression<Func<T, object>> mapperField)
@ -609,15 +615,8 @@ namespace SqlSugar
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();
var sql = QueryBuilder.ToSqlString();
var tableName = this.SqlBuilder.GetPackTable(sql, "MergeTable");
var mergeQueryable = this.Context.Queryable<ExpandoObject>();
mergeQueryable.QueryBuilder.Parameters = QueryBuilder.Parameters;
mergeQueryable.QueryBuilder.WhereIndex = QueryBuilder.WhereIndex + 1;
mergeQueryable.QueryBuilder.JoinIndex = QueryBuilder.JoinIndex + 1;
mergeQueryable.QueryBuilder.LambdaExpressions.ParameterIndex = QueryBuilder.LambdaExpressions.ParameterIndex;
return mergeQueryable.AS(tableName).Select<T>("*");
var sqlobj = this.ToSql();
return this.Context.Queryable<T>().AS(SqlBuilder.GetPackTable(sqlobj.Key, "MergeTable")).AddParameters(sqlobj.Value).Select("*").With(SqlWith.Null);
}
public ISugarQueryable<T> Distinct()
@ -3387,6 +3386,41 @@ namespace SqlSugar
_GroupBy(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5> Having(Expression<Func<T, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5> Having(Expression<Func<T, T2, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5> Having(Expression<Func<T, T2, T3, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5> Having(Expression<Func<T, T2, T3, T4, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4,T5> Having(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
{
this._Having(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4,T5> Having(string whereString, object whereObj)
{
base.Having(whereString, whereObj);
return this;
}
#endregion
#region Aggr
@ -3774,6 +3808,46 @@ namespace SqlSugar
_GroupBy(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6> Having(Expression<Func<T, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5, T6> Having(Expression<Func<T, T2, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5, T6> Having(Expression<Func<T, T2, T3, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5, T6> Having(Expression<Func<T, T2, T3, T4, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5, T6> Having(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
{
this._Having(expression);
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5, T6> Having(Expression<Func<T, T2, T3, T4, T5,T6, bool>> expression)
{
this._Having(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5,T6> Having(string whereString, object whereObj)
{
base.Having(whereString, whereObj);
return this;
}
#endregion
#region Aggr

17
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs

@ -323,6 +323,23 @@ namespace SqlSugar
#endregion
#region Private methods
internal string GetN()
{
var N = "N";
if (_Context.CurrentConnectionConfig.MoreSettings != null && _Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
{
N = "";
}
return N;
}
internal bool IsVarchar()
{
if (_Context.CurrentConnectionConfig.MoreSettings != null && _Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
{
return true;
}
return false;
}
private static void CheckDbDependency(ConnectionConfig config)
{
switch (config.DbType)

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

@ -315,68 +315,7 @@ namespace SqlSugar
return this;
}
#region delete obj
[Obsolete]
public IUpdateable<T> UpdateColumns(Expression<Func<T, bool>> columns)
{
return this.SetColumns(columns);
}
[Obsolete]
public IUpdateable<T> UpdateColumns(Expression<Func<T, T>> columns)
{
return this.SetColumns(columns);
}
[Obsolete]
public IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, Expression<Func<T, T>> columns)
{
return this.SetColumnsIF(isUpdateColumns, columns);
}
[Obsolete]
public IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, Expression<Func<T, bool>> columns)
{
return this.SetColumnsIF(isUpdateColumns, columns);
}
[Obsolete]
public IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, Func<string, bool> updateColumMethod)
{
if (isUpdateColumns)
UpdateColumns(updateColumMethod);
return this;
}
[Obsolete]
public IUpdateable<T> UpdateColumns(Func<string, bool> updateColumMethod)
{
List<string> primaryKeys = GetPrimaryKeys();
foreach (var item in this.UpdateBuilder.DbColumnInfoList)
{
var mappingInfo = primaryKeys.SingleOrDefault(i => item.DbColumnName.Equals(i, StringComparison.CurrentCultureIgnoreCase));
if (mappingInfo != null && mappingInfo.Any())
{
item.IsPrimarykey = true;
}
}
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => updateColumMethod(it.PropertyName) || it.IsPrimarykey || it.IsIdentity).ToList();
return this;
}
[Obsolete]
public IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod)
{
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => !ignoreColumMethod(it.PropertyName)).ToList();
return this;
}
[Obsolete("Use IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);")]
public IUpdateable<T> Where(bool isUpdateNull, bool IsOffIdentity = false)
{
UpdateBuilder.IsOffIdentity = IsOffIdentity;
if (this.UpdateBuilder.LambdaExpressions == null)
this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
this.UpdateBuilder.IsNoUpdateNull = isUpdateNull;
return this;
}
#endregion
#region Helper
private void AppendSets()

6
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/ConnMoreSettings.cs

@ -9,10 +9,8 @@ namespace SqlSugar
{
public bool IsAutoRemoveDataCache { get; set;