Browse Source

Update Core

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
5c4ec2e54a
  1. BIN
      Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite
  2. 8
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs
  3. 1
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs
  4. 1
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  5. 5
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs
  6. 1
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/Method/IDbMethods.cs
  7. 14
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs
  8. 11
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs
  9. 7
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  10. 4
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs
  11. 22
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarClient.cs
  12. 2
      Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec

BIN
Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite

Binary file not shown.

8
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs

@ -52,7 +52,7 @@ namespace SqlSugar
private static readonly MethodInfo getConvertGuid = typeof(IDataRecordExtensions).GetMethod("GetConvertGuid");
private static readonly MethodInfo getConvertInt16 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt16");
private static readonly MethodInfo getConvertInt32 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt32");
private static readonly MethodInfo getConvetInt64 = typeof(IDataRecordExtensions).GetMethod("GetConvetInt64");
private static readonly MethodInfo getConvertInt64 = typeof(IDataRecordExtensions).GetMethod("GetConvetInt64");
private static readonly MethodInfo getConvertEnum_Null = typeof(IDataRecordExtensions).GetMethod("GetConvertEnum_Null");
private static readonly MethodInfo getOtherNull = typeof(IDataRecordExtensions).GetMethod("GetOtherNull");
private static readonly MethodInfo getOther = typeof(IDataRecordExtensions).GetMethod("GetOther");
@ -218,8 +218,10 @@ namespace SqlSugar
{
case CSharpDataType.@int:
CheckType(bind.IntThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName.IsContainsIn("int", "int32", "int64"))
if (bindProperyTypeName.IsContainsIn("int", "int32"))
method = isNullableType ? getConvertInt32 : getInt32;
if (bindProperyTypeName.IsContainsIn("int64"))
method = isNullableType ? getConvertInt64 : getInt64;
break;
case CSharpDataType.@bool:
if (bindProperyTypeName == "bool" || bindProperyTypeName == "boolean")
@ -267,7 +269,7 @@ namespace SqlSugar
break;
case CSharpDataType.@long:
if (bindProperyTypeName == "int64" || bindProperyTypeName == "long")
method = isNullableType ? getConvetInt64 : getInt64;
method = isNullableType ? getConvertInt64 : getInt64;
break;
default:
method = getValueMethod;

1
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs

@ -227,6 +227,7 @@ namespace SqlSugar
result = "DateTime.Now";
}
result = result.Replace("\r", "\t").Replace("\n", "\t");
result = result.IsIn("''","\"\"") ? string.Empty : result;
return result;
}
private string GetPropertyText(DbColumnInfo item, string PropertyText)

1
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -117,6 +117,7 @@ namespace SqlSugar
}
public virtual ISugarQueryable<T> Where(string whereString, object whereObj = null)
{
if (whereString.IsValuable())
this.Where<T>(whereString, whereObj);
return this;
}

5
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs

@ -270,5 +270,10 @@ namespace SqlSugar
{
return "( 1 = 2 ) ";
}
public string GuidNew()
{
return "'"+Guid.NewGuid()+"' ";
}
}
}

1
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/Method/IDbMethods.cs

@ -49,5 +49,6 @@ namespace SqlSugar
string MappingColumn(MethodCallExpressionModel model);
string True();
string False();
string GuidNew();
}
}

14
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

@ -235,6 +235,20 @@ namespace SqlSugar
};
return methodCallExpressionArgs;
}
protected string GetNewExpressionValue(Expression item)
{
var newContext = this.Context.GetCopyContext();
newContext.Resolve(item, this.Context.IsJoin ? ResolveExpressType.WhereMultiple : ResolveExpressType.WhereSingle);
this.Context.Index = newContext.Index;
this.Context.ParameterIndex = newContext.ParameterIndex;
if (newContext.Parameters.IsValuable())
{
this.Context.Parameters.AddRange(newContext.Parameters);
}
return newContext.Result.GetResultString();
}
protected void ResolveNewExpressions(ExpressionParameter parameter, Expression item, string asName)
{
if (item.NodeType == ExpressionType.Constant)

11
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

@ -49,7 +49,13 @@ namespace SqlSugar
MemberAssignment memberAssignment = (MemberAssignment)binding;
var memberName = memberAssignment.Member.Name;
var item = memberAssignment.Expression;
if (item is UnaryExpression||item.NodeType == ExpressionType.Constant || (item is MemberExpression) && ((MemberExpression)item).Expression.NodeType == ExpressionType.Constant)
if ((item is MemberExpression) && ((MemberExpression)item).Expression == null)
{
var paramterValue = ExpressionTool.DynamicInvoke(item);
string parameterName = AppendParameter(paramterValue);
this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
}
else if (item is UnaryExpression || item.NodeType == ExpressionType.Constant || (item is MemberExpression) && ((MemberExpression)item).Expression.NodeType == ExpressionType.Constant)
{
base.Expression = item;
base.Start();
@ -80,7 +86,8 @@ namespace SqlSugar
}
else if (item is BinaryExpression)
{
Check.ThrowNotSupportedException(item.GetType().Name);
var result=GetNewExpressionValue(item);
this.Context.Result.Append(base.Context.GetEqString(memberName, result));
}
}
}

7
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -14,13 +14,18 @@ namespace SqlSugar
var express = base.Expression as MethodCallExpression;
var isLeft = parameter.IsLeft;
string methodName = express.Method.Name;
if (methodName == "get_Item") {
if (methodName == "get_Item")
{
string paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
this.Context.Result.Append(string.Format(" {0} ", paramterName));
this.Context.ParameterIndex++;
return;
}
else if (methodName == "NewGuid") {
this.Context.Result.Append(this.Context.DbMehtods.GuidNew());
return;
}
var isValidNativeMethod = MethodMapping.ContainsKey(methodName)&&express.Method.DeclaringType.Namespace==("System");
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic")&&methodName=="Contains") {
methodName = "ContainsArray";

4
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs

@ -17,5 +17,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1c022a5c-4e4d-4026-a8a3-f659b9740a1a")]
[assembly: AssemblyVersion("4.2.0.3")]
[assembly: AssemblyFileVersion("4.2.0.3")]
[assembly: AssemblyVersion("4.2.0.4")]
[assembly: AssemblyFileVersion("4.2.0.4")]

22
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarClient.cs

@ -224,6 +224,25 @@ namespace SqlSugar
queryable.Where(joinExpression);
return queryable;
}
public virtual List<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
{
if (queryables.IsNullOrEmpty()) return new List<T>();
List<T> result = new List<T>();
foreach (var item in queryables)
{
var addItems = item.ToList();
if (addItems.IsValuable())
{
result.AddRange(addItems);
}
}
return result;
}
public virtual List<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
{
if (queryables.IsNullOrEmpty()) return new List<T>();
return UnionAll(queryables.ToArray());
}
#endregion
#region Insertable
@ -383,7 +402,8 @@ namespace SqlSugar
{
get
{
if (_SimpleClient == null) {
if (_SimpleClient == null)
{
_SimpleClient = new SimpleClient(this);
}
return _SimpleClient;

2
Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec

@ -2,7 +2,7 @@
<package >
<metadata>
<id>sqlSugarCore</id>
<version>4.2.0.3</version>
<version>4.2.0.4</version>
<authors>sunkaixuan</authors>
<owners>Landa</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>

Loading…
Cancel
Save