Browse Source

Update core

pull/14/head
sunkaixuan 3 years ago
parent
commit
456b75355a
  1. 7
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
  2. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs
  3. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
  4. 8
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs
  5. 22
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  6. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs
  7. 24
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs
  8. 22
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/SugarConnection.cs
  9. 20
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs
  10. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  11. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IAdo.cs
  12. 1
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IDbMaintenance.cs
  13. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs
  14. 13
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerExpressionContext.cs
  15. 2
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugar.csproj
  16. 6
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarForCore.nuspec
  17. 4
      Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarForCoreNoDrive.nuspec

7
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/AdoProvider/AdoProvider.cs

@ -77,10 +77,15 @@ namespace SqlSugar
{
CheckConnection();
}
public virtual void OpenAlways()
public SugarConnection OpenAlways()
{
SugarConnection result = new SugarConnection();
result.IsAutoClose = this.Context.CurrentConnectionConfig.IsAutoCloseConnection;
result.conn = this.Connection;
result.Context = this.Context;
this.Context.CurrentConnectionConfig.IsAutoCloseConnection = false;
this.Open();
return result;
}
public virtual void Close()
{

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

@ -325,6 +325,12 @@ namespace SqlSugar
this.Context.Ado.ExecuteCommand(sql);
return true;
}
public virtual bool CreateIndex(string tableName, string[] columnNames, string IndexName, bool isUnique = false)
{
string sql = string.Format("CREATE {3} INDEX {2} ON {0}({1})", tableName, string.Join(",", columnNames), IndexName, isUnique ? "UNIQUE" : "");
this.Context.Ado.ExecuteCommand(sql);
return true;
}
public virtual bool IsAnyIndex(string indexName)
{
string sql = string.Format(this.IsAnyIndexSql, indexName);

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

@ -166,7 +166,7 @@ namespace SqlSugar
{
return string.Empty;
}
return xeNode.Element("summary").Value.Trim();
return xeNode.Element("summary").Value.ToSqlFilter().Trim();
}
/// <summary>
/// Gets the code annotation for the database table

8
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs

@ -99,6 +99,10 @@ namespace SqlSugar
var removeCacheFunc = inserable.RemoveCacheFunc;
var objects = inserable.InsertObjs;
var identityList = inserable.EntityInfo.Columns.Where(it => it.IsIdentity).Select(it => it.PropertyName).ToArray();
if (inserable.IsOffIdentity)
{
identityList = new string[] { };
}
this.Context.Utilities.PageEach(objects, 100, pagelist =>
{
@ -120,6 +124,10 @@ namespace SqlSugar
var removeCacheFunc = inserable.RemoveCacheFunc;
var objects = inserable.InsertObjs;
var identityList = inserable.EntityInfo.Columns.Where(it => it.IsIdentity).Select(it => it.PropertyName).ToArray();
if (inserable.IsOffIdentity)
{
identityList = new string[] { };
}
await this.Context.Utilities.PageEachAsync(objects, 100,async pagelist =>
{

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

@ -485,6 +485,18 @@ namespace SqlSugar
FieldName = column.DbColumnName,
FieldValue = value.ObjToString()
});
if (value != null && value.GetType().IsEnum())
{
if (this.Context.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString == true)
{
}
else
{
data.Value.FieldValue = Convert.ToInt64(value).ObjToString();
}
}
cons.ConditionalList.Add(data);
if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)
{
@ -1136,16 +1148,16 @@ namespace SqlSugar
var parentIdName = UtilConvert.ToMemberExpression((parentIdExpression as LambdaExpression).Body).Member.Name;
var ParentInfo = entity.Columns.First(it => it.PropertyName == parentIdName);
var parentPropertyName = ParentInfo.DbColumnName;
var current =await this.Context.Queryable<T>().InSingleAsync(primaryKeyValue);
var current =await this.Context.Queryable<T>().AS(this.QueryBuilder.GetTableNameString).InSingleAsync(primaryKeyValue);
if (current != null)
{
result.Add(current);
object parentId = ParentInfo.PropertyInfo.GetValue(current, null);
int i = 0;
while (parentId != null &&await this.Context.Queryable<T>().In(parentId).AnyAsync())
while (parentId != null &&await this.Context.Queryable<T>().AS(this.QueryBuilder.GetTableNameString).In(parentId).AnyAsync())
{
Check.Exception(i > 100, ErrorMessage.GetThrowMessage("Dead cycle", "出现死循环或超出循环上限(100),检查最顶层的ParentId是否是null或者0"));
var parent =await this.Context.Queryable<T>().InSingleAsync(parentId);
var parent =await this.Context.Queryable<T>().AS(this.QueryBuilder.GetTableNameString).InSingleAsync(parentId);
result.Add(parent);
parentId = ParentInfo.PropertyInfo.GetValue(parent, null);
++i;
@ -2161,6 +2173,10 @@ namespace SqlSugar
Check.Exception(true, ".Mapper() parameter error");
}
List<string> inValues = entitys.Select(it => it.GetType().GetProperty(filedName).GetValue(it, null).ObjToString()).ToList();
if (inValues!=null&& inValues.Any()&&UtilMethods.GetUnderType(entitys.First().GetType().GetProperty(filedName).PropertyType) == UtilConstants.GuidType)
{
inValues = inValues.Select(x => x == "" ? "null" : x).Distinct().ToList();
}
List<IConditionalModel> wheres = new List<IConditionalModel>()
{
new ConditionalModel()

6
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -243,7 +243,7 @@ namespace SqlSugar
}
resolveExpress.RootExpression = expression;
resolveExpress.JoinQueryInfos = Builder.QueryBuilder.JoinQueryInfos;
resolveExpress.IsSingle = IsSingle();
resolveExpress.IsSingle = IsSingle()&& resolveType!= ResolveExpressType.WhereMultiple;
resolveExpress.MappingColumns = Context.MappingColumns;
resolveExpress.MappingTables = Context.MappingTables;
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
@ -641,12 +641,12 @@ namespace SqlSugar
result += UtilConstants.Space;
if (IsSingle() && result.Contains("MergeTable") && result.Trim().EndsWith(" MergeTable") && TableShortName != null)
{
result = result.Replace(") MergeTable ", ") " + TableShortName);
result = result.Replace(") MergeTable ", ") " + TableShortName+UtilConstants.Space);
TableShortName = null;
}
if (IsSingle() && result.Contains("unionTable") && result.Trim().EndsWith(" unionTable")&& TableShortName!=null)
{
result = result.Replace(" ) unionTable ", ") "+TableShortName);
result = result.Replace(" ) unionTable ", ") "+TableShortName + UtilConstants.Space);
TableShortName = null;
}
if (this.TableShortName.HasValue())

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

@ -189,12 +189,36 @@ namespace SqlSugar
case ConditionalType.In:
if (item.FieldValue == null) item.FieldValue = string.Empty;
var inValue1 = ("(" + item.FieldValue.Split(',').ToJoinSqlInVals() + ")");
if (item.CSharpTypeName.HasValue()&&UtilMethods.IsNumber(item.CSharpTypeName))
{
inValue1= inValue1.Replace("'","");
}
else if(inValue1.Contains("'null'"))
{
inValue1 = inValue1.Replace("'null'", "null");
}
else if (inValue1.Contains("[null]"))
{
inValue1 = inValue1.Replace("[null]", "null");
}
builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "IN", inValue1);
parameters.Add(new SugarParameter(parameterName, item.FieldValue));
break;
case ConditionalType.NotIn:
if (item.FieldValue == null) item.FieldValue = string.Empty;
var inValue2 = ("(" + item.FieldValue.Split(',').ToJoinSqlInVals() + ")");
if (item.CSharpTypeName.HasValue() && UtilMethods.IsNumber(item.CSharpTypeName))
{
inValue2 = inValue2.Replace("'", "");
}
else if (inValue2.Contains("'null'"))
{
inValue2 = inValue2.Replace("'null'", "null");
}
else if (inValue2.Contains("[null]"))
{
inValue2 = inValue2.Replace("[null]", "null");
}
builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "NOT IN", inValue2);
parameters.Add(new SugarParameter(parameterName, item.FieldValue));
break;

22
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/SugarConnection.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class SugarConnection:IDisposable
{
public IDbConnection conn { get; set; }
public bool IsAutoClose { get; set; }
public ISqlSugarClient Context { get; set; }
public void Dispose()
{
conn.Close();
this.Context.CurrentConnectionConfig.IsAutoCloseConnection = IsAutoClose;
}
}
}

20
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

@ -532,6 +532,26 @@ namespace SqlSugar
{
return false;
}
else if ((item as MethodCallExpression).Method.Name== "AggregateMax")
{
return false;
}
else if ((item as MethodCallExpression).Method.Name == "AggregateMin")
{
return false;
}
else if ((item as MethodCallExpression).Method.Name == "AggregateSum")
{
return false;
}
else if ((item as MethodCallExpression).Method.Name == "ToBool")
{
return false;
}
else if ((item as MethodCallExpression).Method.Name == "ToBoolean")
{
return false;
}
else
{
return true;

4
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -1006,6 +1006,10 @@ namespace SqlSugar
{
return string.Format("CONVERT(varchar(100),convert(datetime,{0}), {1})", value, formatString);
}
else if (IsSqlServer())
{
return string.Format("FORMAT({0},'{1}','en-US')", value, formatString);
}
var parameter = new MethodCallExpressionArgs() { IsMember = true, MemberValue = DateType.Year };
var parameter2 = new MethodCallExpressionArgs() { IsMember = true, MemberName = value };
var parameters = new MethodCallExpressionModel() { Args = new List<MethodCallExpressionArgs>() { parameter2, parameter } };

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IAdo.cs

@ -163,7 +163,7 @@ namespace SqlSugar
void Dispose();
void Close();
void Open();
void OpenAlways();
SugarConnection OpenAlways();
void CheckConnection();
void BeginTran();

1
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IDbMaintenance.cs

@ -29,6 +29,7 @@ namespace SqlSugar
#region DDL
bool AddDefaultValue(string tableName,string columnName,string defaultValue);
bool CreateIndex(string tableName, string [] columnNames, bool isUnique=false);
bool CreateIndex(string tableName, string[] columnNames, string IndexName, bool isUnique = false);
bool DropTable(string tableName);
bool TruncateTable(string tableName);
bool TruncateTable<T>();

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

@ -12,7 +12,7 @@ namespace SqlSugar
{
get
{
return "SELECT NAME FROM MASTER.DBO.SYSDATABASES ORDER BY NAME";
return "SELECT NAME FROM master.dbo.sysdatabases ORDER BY NAME";
}
}
protected override string GetColumnInfosByTableNameSql

13
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerExpressionContext.cs

@ -20,6 +20,19 @@ namespace SqlSugar
}
public partial class SqlServerMethod : DefaultDbMethod, IDbMethods
{
public override string DateValue(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
if (parameter.MemberName != null && parameter.MemberName is DateTime)
{
return string.Format(" datepart({0},'{1}') ", parameter2.MemberValue, parameter.MemberName);
}
else
{
return string.Format(" datepart({0},{1}) ", parameter2.MemberValue, parameter.MemberName);
}
}
public override string HasValue(MethodCallExpressionModel model)
{
if (model.Args[0].Type == UtilConstants.GuidType)

2
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugar.csproj

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>5.0.5.9</Version>
<Version>5.0.6</Version>
<Copyright>sun_kai_xuan</Copyright>
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
<PackageLicenseUrl></PackageLicenseUrl>

6
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarForCore.nuspec

@ -2,16 +2,16 @@
<package >
<metadata>
<id>SqlSugarCore</id>
<version>5.0.5.9</version>
<version>5.0.6</version>
<authors>sunkaixuan</authors>
<owners>Landa</owners>
<owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
<projectUrl>https://github.com/sunkaixuan/SqlSugar</projectUrl>
<iconUrl>https://secure.gravatar.com/avatar/a82c03402497b2e58fd65038a3699b30</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>5.0.3.5-Max 最低要求.Net Core 3.0+ ,5.0.0-5.0.3.4 最低要求 .Net Core 2.0+ SqlSugar ORM ,High-performance, lightweight </description>
<copyright>Copyright 2016</copyright>
<tags>Asp.net core orm</tags>
<tags>SqlSugar Sql Sugar core Asp.net core orm</tags>
<dependencies>
<group targetFramework=".NETStandard2.1">
<dependency id="System.Data.Common" version="4.3.0" />

4
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugarForCoreNoDrive.nuspec

@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugarCoreNoDrive</id>
<version>5.0.5.9</version>
<version>5.0.6</version>
<authors>sunkaixuan</authors>
<owners>Landa</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description> .Net Core/.net5 SqlSugar ORM ,High-performance, lightweight https://github.com/sunkaixuan/SqlSugar</description>
<copyright>Copyright 2016</copyright>
<tags>Asp.net core orm</tags>
<tags>SqlSugar Sql Sugar Core Asp.net core orm</tags>
<dependencies>
<group targetFramework=".NETStandard2.1">
<dependency id="System.Data.Common" version="4.3.0" />

Loading…
Cancel
Save