Browse Source

Update core

pull/3/head
sunkaixuna 3 years ago
parent
commit
c52d05f2d9
  1. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs
  2. 1
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs
  3. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubInnerJoin.cs
  4. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubLeftJoin.cs
  5. 9
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs
  6. 9
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs
  7. 3
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubSelect.cs
  8. 9
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs
  9. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/SubResolve.cs
  10. 16
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs
  11. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs
  12. 7
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs
  13. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarClient.cs

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

@ -35,6 +35,10 @@ namespace SqlSugar
{ {
return name; return name;
} }
if (Context.MappingTables == null)
{
return name;
}
var context = this.Context; var context = this.Context;
var mappingInfo = context var mappingInfo = context
.MappingTables .MappingTables

1
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs

@ -60,6 +60,7 @@ namespace SqlSugar
} }
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot; var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result; return result;
} }

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubInnerJoin.cs

@ -50,7 +50,7 @@ namespace SqlSugar
var joinString =string.Format(" {2} INNER JOIN {1} {0} ", var joinString =string.Format(" {2} INNER JOIN {1} {0} ",
this.Context.GetTranslationColumnName(parameter.Name), this.Context.GetTranslationColumnName(parameter.Name),
tableName, tableName,
this.Context.JoinIndex==0?name:""); this.Context.JoinIndex==1?name:"");
var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
//var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot; //var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
this.Context.JoinIndex++; this.Context.JoinIndex++;

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubLeftJoin.cs

@ -50,7 +50,7 @@ namespace SqlSugar
var joinString =string.Format(" {2} LEFT JOIN {1} {0} ", var joinString =string.Format(" {2} LEFT JOIN {1} {0} ",
this.Context.GetTranslationColumnName(parameter.Name), this.Context.GetTranslationColumnName(parameter.Name),
tableName, tableName,
this.Context.JoinIndex==0?name:""); this.Context.JoinIndex==1?name:"");
var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
//var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot; //var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
this.Context.JoinIndex++; this.Context.JoinIndex++;

9
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs

@ -49,6 +49,15 @@ namespace SqlSugar
{ {
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand; argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
} }
var argLambda = argExp as LambdaExpression;
if (this.Context.InitMappingInfo != null && argLambda != null && argLambda.Parameters.Count > 0)
{
foreach (var item in argLambda.Parameters)
{
this.Context.InitMappingInfo(item.Type);
}
this.Context.RefreshMapping();
}
var result = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")"; var result = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));

9
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs

@ -49,6 +49,15 @@ namespace SqlSugar
{ {
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand; argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
} }
var argLambda = argExp as LambdaExpression;
if (this.Context.InitMappingInfo != null && argLambda != null && argLambda.Parameters.Count > 0)
{
foreach (var item in argLambda.Parameters)
{
this.Context.InitMappingInfo(item.Type);
}
this.Context.RefreshMapping();
}
var result = "MIN(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")"; var result = "MIN(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));

3
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubSelect.cs

@ -49,7 +49,10 @@ namespace SqlSugar
this.Context.InitMappingInfo(entityType); this.Context.InitMappingInfo(entityType);
this.Context.RefreshMapping(); this.Context.RefreshMapping();
} }
if(this.Context.JoinIndex==0)
return SubTools.GetMethodValue(this.Context, exp.Arguments[0],ResolveExpressType.FieldSingle); return SubTools.GetMethodValue(this.Context, exp.Arguments[0],ResolveExpressType.FieldSingle);
else
return SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldMultiple);
} }
} }
} }

9
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Items/SubSum.cs

@ -49,6 +49,15 @@ namespace SqlSugar
{ {
argExp =((argExp as LambdaExpression).Body as UnaryExpression).Operand; argExp =((argExp as LambdaExpression).Body as UnaryExpression).Operand;
} }
var argLambda = argExp as LambdaExpression;
if (this.Context.InitMappingInfo != null&& argLambda != null&&argLambda.Parameters.Count>0)
{
foreach (var item in argLambda.Parameters)
{
this.Context.InitMappingInfo(item.Type);
}
this.Context.RefreshMapping();
}
var result = "SUM(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple)+")"; var result = "SUM(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple)+")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot; var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));

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

@ -135,11 +135,17 @@ namespace SqlSugar
} }
isubList = isubList.OrderBy(it => it.Sort).ToList(); isubList = isubList.OrderBy(it => it.Sort).ToList();
var isHasWhere = isubList.Where(it => it is SubWhere).Any(); var isHasWhere = isubList.Where(it => it is SubWhere).Any();
var isJoin = isubList.Any(it => it is SubInnerJoin || it is SubLeftJoin);
if (isJoin)
{
this.context.JoinIndex++;
}
List<string> result = isubList.Select(it => List<string> result = isubList.Select(it =>
{ {
it.HasWhere = isHasWhere; it.HasWhere = isHasWhere;
return it.GetValue(it.Expression); return it.GetValue(it.Expression);
}).ToList(); }).ToList();
this.context.JoinIndex = 0;
return result; return result;
} }
} }

16
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs

@ -27,6 +27,22 @@ namespace SqlSugar
{ {
return this; return this;
} }
public Subqueryable<T> Where<Main, Join1>(Func<Main, Join1, bool> expression)
{
return this;
}
public Subqueryable<T> Where<Main, Join1, Join2>(Func<Main, Join1, Join2, bool> expression)
{
return this;
}
public Subqueryable<T> Where<Main, Join1, Join2, Join3>(Func<Main, Join1, Join2, Join3, bool> expression)
{
return this;
}
public Subqueryable<T> Where<Main, Join1, Join2, Join3, Join4>(Func<Main, Join1, Join2, Join3, Join4, bool> expression)
{
return this;
}
public Subqueryable<T> WhereIF(bool isWhere,Func<T, bool> expression) public Subqueryable<T> WhereIF(bool isWhere,Func<T, bool> expression)
{ {
return this; return this;

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs

@ -136,6 +136,8 @@ namespace SqlSugar
typeName = "long"; typeName = "long";
if (typeName == "int16") if (typeName == "int16")
typeName = "short"; typeName = "short";
if (typeName == "boolean")
typeName = "bool";
var isAnyType = PostgreSQLDbBind.MappingTypesConst.Where(x => x.Value.ToString().ToLower() == typeName).Any(); var isAnyType = PostgreSQLDbBind.MappingTypesConst.Where(x => x.Value.ToString().ToLower() == typeName).Any();
if (isAnyType) if (isAnyType)

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

@ -322,12 +322,19 @@ namespace SqlSugar
public override bool CreateDatabase(string databaseName, string databaseDirectory = null) public override bool CreateDatabase(string databaseName, string databaseDirectory = null)
{ {
if (databaseDirectory != null) if (databaseDirectory != null)
{
try
{ {
if (!FileHelper.IsExistDirectory(databaseDirectory)) if (!FileHelper.IsExistDirectory(databaseDirectory))
{ {
FileHelper.CreateDirectory(databaseDirectory); FileHelper.CreateDirectory(databaseDirectory);
} }
} }
catch
{
//Databases and sites are not in the same service
}
}
var oldDatabaseName = this.Context.Ado.Connection.Database; var oldDatabaseName = this.Context.Ado.Connection.Database;
var connection = this.Context.CurrentConnectionConfig.ConnectionString; var connection = this.Context.CurrentConnectionConfig.ConnectionString;
connection = connection.Replace(oldDatabaseName, "master"); connection = connection.Replace(oldDatabaseName, "master");

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

@ -589,6 +589,10 @@ namespace SqlSugar
db.Context = new SqlSugarProvider(db.ConnectionConfig); db.Context = new SqlSugarProvider(db.ConnectionConfig);
} }
var intiAop=db.Context.Aop; var intiAop=db.Context.Aop;
if (db.Context.CurrentConnectionConfig.AopEvents == null)
{
db.Context.CurrentConnectionConfig.AopEvents = new AopEvents();
}
return db.Context; return db.Context;
} }
public void ChangeDatabase(dynamic configId) public void ChangeDatabase(dynamic configId)

Loading…
Cancel
Save