修正拼写错误

This commit is contained in:
2248356998 qq.com
2025-07-19 22:36:13 +08:00
parent 9921130406
commit f95590b4cb
85 changed files with 689 additions and 562 deletions

View File

@@ -60,10 +60,10 @@ public class SugarAopService : ISugarAopService
//异常
db.Aop.OnError = (ex) =>
{
if (ex.Parametres == null) return;
if (ex.Parameters == null) return;
Console.ForegroundColor = ConsoleColor.Red;
DbContext.WriteLog($"{config.ConfigId}库操作异常");
DbContext.WriteErrorLogWithSql(UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres));
DbContext.WriteErrorLogWithSql(UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parameters));
NewLife.Log.XTrace.WriteException(ex);
Console.ForegroundColor = ConsoleColor.White;
};

View File

@@ -500,7 +500,7 @@ public static class App
//{
// continue;
//}
var loadedAssembly = Reflect.LoadAssembly(assemblyFileFullPath);
if (loadedAssembly == default) continue;

View File

@@ -13,8 +13,8 @@ namespace System.Diagnostics
public StackFrame StackFrame { get; }
public bool IsRecursive
{
public bool IsRecursive
{
get => MethodInfo.RecurseCount > 0;
internal set => MethodInfo.RecurseCount++;
}

View File

@@ -3,17 +3,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic.Enumerable;
using System.Diagnostics.Internal;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace System.Diagnostics
{
@@ -615,7 +610,7 @@ namespace System.Diagnostics
}
}
if (parameterType.IsByRef && parameterType.GetElementType() is {} elementType)
if (parameterType.IsByRef && parameterType.GetElementType() is { } elementType)
{
parameterType = elementType;
}
@@ -771,10 +766,10 @@ namespace System.Diagnostics
case "Trampoline":
return false;
case var typeName when type.IsGenericType:
{
if (typeName == "AsyncResult`1") return false;
else break;
}
{
if (typeName == "AsyncResult`1") return false;
else break;
}
}
}

View File

@@ -1,10 +1,7 @@
// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic.Enumerable;
using System.IO;
using System.Text;
namespace System.Diagnostics
@@ -101,8 +98,8 @@ namespace System.Diagnostics
sb.Append(" at ");
frame.MethodInfo.Append(sb);
if (frame.GetFileName() is {} fileName
if (frame.GetFileName() is { } fileName
// IsNullOrEmpty alone wasn't enough to disable the null warning
&& !string.IsNullOrEmpty(fileName))
{

View File

@@ -1,7 +1,6 @@
// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Generic.Enumerable;
using System.Reflection;
using System.Text;
@@ -57,7 +56,7 @@ namespace System.Diagnostics
/// computes a demystified string representation and then restores the original state of the exception back.
/// </remarks>
[Contracts.Pure]
public static string ToStringDemystified(this Exception exception)
public static string ToStringDemystified(this Exception exception)
=> new StringBuilder().AppendDemystified(exception).ToString();
}
}

View File

@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
@@ -104,8 +102,8 @@ namespace System.Diagnostics.Internal
{
var codeViewData = peReader.ReadCodeViewDebugDirectoryData(entry);
var peDirectory = Path.GetDirectoryName(assemblyPath);
return peDirectory is null
? null
return peDirectory is null
? null
: Path.Combine(peDirectory, Path.GetFileName(codeViewData.Path));
}
}

View File

@@ -1,9 +1,7 @@
// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
namespace System.Diagnostics.Internal
{

View File

@@ -12,7 +12,7 @@ namespace System.Diagnostics
public MethodBase? MethodBase { get; set; }
public Type? DeclaringType { get; set; }
public bool IsAsync { get; set; }
public bool IsLambda { get; set; }
@@ -38,8 +38,8 @@ namespace System.Diagnostics
internal bool IsSequentialEquivalent(ResolvedMethod obj)
{
return
IsAsync == obj.IsAsync &&
return
IsAsync == obj.IsAsync &&
DeclaringType == obj.DeclaringType &&
Name == obj.Name &&
IsLambda == obj.IsLambda &&
@@ -98,7 +98,7 @@ namespace System.Diagnostics
if (MethodBase != null)
{
var isFirst = true;
foreach(var param in Parameters)
foreach (var param in Parameters)
{
if (isFirst)
{

View File

@@ -22,7 +22,7 @@ namespace System.Diagnostics
{
if (ResolvedType.Assembly.ManifestModule.Name == "FSharp.Core.dll" && ResolvedType.Name == "Unit")
return sb;
if (!string.IsNullOrEmpty(Prefix))
{
sb.Append(Prefix)
@@ -51,7 +51,7 @@ namespace System.Diagnostics
return sb;
}
protected virtual void AppendTypeName(StringBuilder sb)
protected virtual void AppendTypeName(StringBuilder sb)
{
sb.AppendTypeDisplayName(ResolvedType, fullName: false, includeGenericParameterNames: true);
}

View File

@@ -4,7 +4,7 @@
using System.Collections.Generic.Enumerable;
using System.Text;
namespace System.Diagnostics
namespace System.Diagnostics
{
public static class StringBuilderExtentions
{
@@ -47,7 +47,7 @@ namespace System.Diagnostics
return builder;
}
private static void AppendInnerException(this StringBuilder builder, Exception exception)
private static void AppendInnerException(this StringBuilder builder, Exception exception)
=> builder.Append(" ---> ")
.AppendDemystified(exception)
.AppendLine()

View File

@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Text;
namespace System.Diagnostics
@@ -28,7 +27,7 @@ namespace System.Diagnostics
{ typeof(ulong), "ulong" },
{ typeof(ushort), "ushort" }
};
public static readonly Dictionary<string, string> FSharpTypeNames = new Dictionary<string, string>
{
{ "Unit", "void" },
@@ -101,7 +100,7 @@ namespace System.Diagnostics
{
builder.Append(type.Name);
}
else if (type.Assembly.ManifestModule.Name == "FSharp.Core.dll"
else if (type.Assembly.ManifestModule.Name == "FSharp.Core.dll"
&& FSharpTypeNames.TryGetValue(type.Name, out builtInName))
{
builder.Append(builtInName);
@@ -174,7 +173,7 @@ namespace System.Diagnostics
return;
}
if (type.Assembly.ManifestModule.Name == "FSharp.Core.dll"
if (type.Assembly.ManifestModule.Name == "FSharp.Core.dll"
&& FSharpTypeNames.TryGetValue(type.Name, out var builtInName))
{
builder.Append(builtInName);

View File

@@ -1,18 +1,17 @@
// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics.Internal;
using System.Text;
namespace System.Diagnostics
namespace System.Diagnostics
{
public class ValueTupleResolvedParameter : ResolvedParameter
{
public IList<string> TupleNames { get; }
public ValueTupleResolvedParameter(Type resolvedType, IList<string> tupleNames)
: base(resolvedType)
public ValueTupleResolvedParameter(Type resolvedType, IList<string> tupleNames)
: base(resolvedType)
=> TupleNames = tupleNames;
protected override void AppendTypeName(StringBuilder sb)

View File

@@ -239,7 +239,9 @@ public sealed class HttpMultipartFormDataBuilder
{
_partContents.Add(new MultipartFormDataItem(name)
{
ContentType = mediaType, RawContent = rawObject, ContentEncoding = encoding
ContentType = mediaType,
RawContent = rawObject,
ContentEncoding = encoding
});
return this;
@@ -526,7 +528,10 @@ public sealed class HttpMultipartFormDataBuilder
_partContents.Add(new MultipartFormDataItem(name)
{
ContentType = mimeType, RawContent = stream, ContentEncoding = encoding, FileName = fileName
ContentType = mimeType,
RawContent = stream,
ContentEncoding = encoding,
FileName = fileName
});
// 是否在请求结束后自动释放流
@@ -569,7 +574,10 @@ public sealed class HttpMultipartFormDataBuilder
_partContents.Add(new MultipartFormDataItem(name)
{
ContentType = mimeType, RawContent = byteArray, ContentEncoding = encoding, FileName = fileName
ContentType = mimeType,
RawContent = byteArray,
ContentEncoding = encoding,
FileName = fileName
});
return this;
@@ -692,7 +700,9 @@ public sealed class HttpMultipartFormDataBuilder
_partContents.Add(new MultipartFormDataItem(formName)
{
ContentType = mediaType, RawContent = httpContent, ContentEncoding = encoding
ContentType = mediaType,
RawContent = httpContent,
ContentEncoding = encoding
});
return this;

View File

@@ -14,7 +14,6 @@ using Microsoft.Net.Http.Headers;
using System.Globalization;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Net.Mime;
using ThingsGateway.Extensions;
@@ -337,7 +336,9 @@ public sealed partial class HttpRequestBuilder
{
httpRequestMessage.Headers.CacheControl = new CacheControlHeaderValue
{
NoCache = true, NoStore = true, MustRevalidate = true
NoCache = true,
NoStore = true,
MustRevalidate = true
};
}

View File

@@ -11,10 +11,11 @@
// ReSharper disable ArrangeObjectCreationWhenTypeNotEvident
using ThingsGateway.Extensions;
using System.Collections.Concurrent;
using System.Reflection;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,10 +9,11 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using System.Net.Mime;
using System.Reflection;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,9 +9,10 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using System.Reflection;
using ThingsGateway.Extensions;
using ThingsGateway.Utilities;
using System.Reflection;
namespace ThingsGateway.HttpRemote;

View File

@@ -9,9 +9,10 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using System.Reflection;
using ThingsGateway.Extensions;
using ThingsGateway.Utilities;
using System.Reflection;
namespace ThingsGateway.HttpRemote;

View File

@@ -9,12 +9,13 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using System.Globalization;
using System.Net.Mime;
using System.Reflection;
using System.Text;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,9 +9,10 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using System.Reflection;
using ThingsGateway.Extensions;
using ThingsGateway.Utilities;
using System.Reflection;
namespace ThingsGateway.HttpRemote;

View File

@@ -9,9 +9,10 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using System.Reflection;
using ThingsGateway.Extensions;
using ThingsGateway.Utilities;
using System.Reflection;
namespace ThingsGateway.HttpRemote;

View File

@@ -9,10 +9,11 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,10 +9,11 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,11 +9,13 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Net.Http.Headers;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote.Extensions;
/// <summary>

View File

@@ -10,6 +10,7 @@
// ------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
using System.Text;
namespace ThingsGateway.HttpRemote;

View File

@@ -9,15 +9,18 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using ThingsGateway.Utilities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Net.Http.Headers;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
using ThingsGateway.Extensions;
using ThingsGateway.Utilities;
using StringWithQualityHeaderValue = System.Net.Http.Headers.StringWithQualityHeaderValue;
namespace ThingsGateway.HttpRemote.Extensions;

View File

@@ -9,14 +9,16 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Utilities;
using Microsoft.Net.Http.Headers;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http.Json;
using System.Net.Mime;
using System.Text.RegularExpressions;
using ThingsGateway.Utilities;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,12 +9,14 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System.Diagnostics;
using System.Threading.Channels;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,12 +9,14 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System.Diagnostics;
using System.Threading.Channels;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,11 +9,13 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System.Threading.Channels;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>

View File

@@ -9,13 +9,15 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Channels;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>
@@ -218,7 +220,7 @@ internal sealed class ServerSentEventsManager
}
// 获取 HTTP 响应体中的内容流
using var contentStream = await httpResponseMessage.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var contentStream = await httpResponseMessage.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
// 初始化 StreamReader 实例
using var streamReader = new StreamReader(contentStream, Encoding.UTF8);

View File

@@ -11,6 +11,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System.Diagnostics;
namespace ThingsGateway.HttpRemote;

View File

@@ -9,16 +9,17 @@
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// ------------------------------------------------------------------------
using ThingsGateway.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using System.Diagnostics;
using System.Net;
using System.Net.Http.Headers;
using System.Reflection;
using System.Text.RegularExpressions;
using ThingsGateway.Extensions;
namespace ThingsGateway.HttpRemote;
/// <summary>
@@ -345,7 +346,8 @@ internal sealed partial class HttpRemoteService : IHttpRemoteService
// 初始化 HttpRemoteResult 实例
var httpRemoteResult = new HttpRemoteResult<TResult>(httpResponseMessage)
{
Result = result, RequestDuration = requestDuration
Result = result,
RequestDuration = requestDuration
};
return httpRemoteResult;
@@ -378,7 +380,8 @@ internal sealed partial class HttpRemoteService : IHttpRemoteService
// 初始化 HttpRemoteResult 实例
var httpRemoteResult = new HttpRemoteResult<TResult>(httpResponseMessage)
{
Result = result, RequestDuration = requestDuration
Result = result,
RequestDuration = requestDuration
};
return httpRemoteResult;

View File

@@ -1,3 +1,3 @@
https://gitee.com/dotnetchina/SqlSugar/commit/c3e1d64cbd3bf42b536bd68bf745216208ede1bb
https://gitee.com/dothttpshttps://gitee.com/dotnetchina/SqlSugar/commit/b8a1e3320a72fb075633845ce2fba2d14f86affe
修改大部分CA规则后期优化减少字符串操作

View File

@@ -55,7 +55,7 @@ namespace ThingsGateway.SqlSugar
"参数格式错误。\n请使用 new{xx=xx, xx2=xx2} 或 \nDictionary<string, object> 或 \nSugarParameter [] ");
// 反射对象属性转参数
ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, result, entityType);
PropertyToParameter(parameters, propertyInfo, sqlParameterKeyWord, result, entityType);
}
}
@@ -65,16 +65,16 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 将对象的属性转换为参数集合
/// </summary>
protected void ProperyToParameter(object parameters, PropertyInfo[] propertyInfo, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
protected void PropertyToParameter(object parameters, PropertyInfo[] propertyInfo, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
{
PropertyInfo[] properties = propertyInfo ?? entityType.GetProperties();
foreach (PropertyInfo properyty in properties)
foreach (PropertyInfo propertyty in properties)
{
var value = properyty.GetValue(parameters, null);
var value = propertyty.GetValue(parameters, null);
// 如果是枚举类型,转成 long
if (properyty.PropertyType.IsEnum())
if (propertyty.PropertyType.IsEnum())
value = Convert.ToInt64(value);
// DateTime.MinValue 处理为 DBNull
@@ -82,9 +82,9 @@ namespace ThingsGateway.SqlSugar
value = DBNull.Value;
// 特殊处理 HIERARCHYID 类型
if (properyty.Name.Contains("hierarchyid", StringComparison.CurrentCultureIgnoreCase))
if (propertyty.Name.Contains("hierarchyid", StringComparison.CurrentCultureIgnoreCase))
{
var parameter = new SugarParameter(sqlParameterKeyWord + properyty.Name, SqlDbType.Udt)
var parameter = new SugarParameter(sqlParameterKeyWord + propertyty.Name, SqlDbType.Udt)
{
UdtTypeName = "HIERARCHYID",
Value = value
@@ -94,7 +94,7 @@ namespace ThingsGateway.SqlSugar
else
{
// 常规参数
var parameter = new SugarParameter(sqlParameterKeyWord + properyty.Name, value);
var parameter = new SugarParameter(sqlParameterKeyWord + propertyty.Name, value);
listParams.Add(parameter);
}
}

View File

@@ -858,67 +858,67 @@ namespace ThingsGateway.SqlSugar
}
var propertyType = UtilMethods.GetUnderType(ec.PropertyInfo);
string properyTypeName;
string propertyTypeName;
if (propertyType.IsEnum())
{
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(ec.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
propertyTypeName = this.Context.Ado.DbBind.GetDbTypeName(ec.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
}
else
{
var name = GetType(propertyType.Name);
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(name);
propertyTypeName = this.Context.Ado.DbBind.GetDbTypeName(name);
}
var dataType = dc.DataType;
if (properyTypeName.Equals("boolean", StringComparison.OrdinalIgnoreCase) && dataType.Equals("bool", StringComparison.OrdinalIgnoreCase))
if (propertyTypeName.Equals("boolean", StringComparison.OrdinalIgnoreCase) && dataType.Equals("bool", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName.Equals("varchar", StringComparison.OrdinalIgnoreCase) &&
if (propertyTypeName.Equals("varchar", StringComparison.OrdinalIgnoreCase) &&
(dataType.Equals("string", StringComparison.OrdinalIgnoreCase) || dataType.Equals("nvarchar", StringComparison.OrdinalIgnoreCase)))
return false;
if (properyTypeName.Equals("number", StringComparison.OrdinalIgnoreCase) && dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase))
if (propertyTypeName.Equals("number", StringComparison.OrdinalIgnoreCase) && dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase))
return false;
if (this.Context.CurrentConnectionConfig?.MoreSettings?.EnableOracleIdentity == true &&
properyTypeName.Equals("int", StringComparison.OrdinalIgnoreCase) && dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase))
propertyTypeName.Equals("int", StringComparison.OrdinalIgnoreCase) && dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName.Equals("int", StringComparison.OrdinalIgnoreCase) &&
if (propertyTypeName.Equals("int", StringComparison.OrdinalIgnoreCase) &&
dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase) &&
dc.Length == 22 && dc.Scale == 0 &&
this.Context.CurrentConnectionConfig.DbType == DbType.Oracle)
return false;
if (properyTypeName.Equals("int", StringComparison.OrdinalIgnoreCase) && dataType.Equals("int32", StringComparison.OrdinalIgnoreCase))
if (propertyTypeName.Equals("int", StringComparison.OrdinalIgnoreCase) && dataType.Equals("int32", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName.Equals("date", StringComparison.OrdinalIgnoreCase) && dataType.Equals("datetime", StringComparison.OrdinalIgnoreCase))
if (propertyTypeName.Equals("date", StringComparison.OrdinalIgnoreCase) && dataType.Equals("datetime", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName.Equals("bigint", StringComparison.OrdinalIgnoreCase) && dataType.Equals("int64", StringComparison.OrdinalIgnoreCase))
if (propertyTypeName.Equals("bigint", StringComparison.OrdinalIgnoreCase) && dataType.Equals("int64", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName.Equals("blob", StringComparison.OrdinalIgnoreCase) && dataType.Equals("byte[]", StringComparison.OrdinalIgnoreCase))
if (propertyTypeName.Equals("blob", StringComparison.OrdinalIgnoreCase) && dataType.Equals("byte[]", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName == null || dataType == null)
if (propertyTypeName == null || dataType == null)
{
return properyTypeName != dataType;
return propertyTypeName != dataType;
}
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer &&
dataType.Equals("timestamp", StringComparison.OrdinalIgnoreCase) &&
properyTypeName.Equals("varbinary", StringComparison.OrdinalIgnoreCase))
propertyTypeName.Equals("varbinary", StringComparison.OrdinalIgnoreCase))
return false;
if (properyTypeName.IsIn("int", "long") && dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase) &&
if (propertyTypeName.IsIn("int", "long") && dataType.Equals("decimal", StringComparison.OrdinalIgnoreCase) &&
dc.Length == 38 && dc.DecimalDigits == 127)
return false;
if (dataType.Equals("numeric", StringComparison.OrdinalIgnoreCase) && properyTypeName.Equals("decimal", StringComparison.OrdinalIgnoreCase))
if (dataType.Equals("numeric", StringComparison.OrdinalIgnoreCase) && propertyTypeName.Equals("decimal", StringComparison.OrdinalIgnoreCase))
return false;
if (ec.UnderType == UtilConstants.BoolType && dc.OracleDataType?.Equals("number", StringComparison.OrdinalIgnoreCase) == true)
@@ -928,12 +928,12 @@ namespace ThingsGateway.SqlSugar
dc.OracleDataType?.Equals("number", StringComparison.OrdinalIgnoreCase) == true)
return false;
if (dataType.EqualCase("timestamp") && properyTypeName.EqualCase("timestamptz"))
if (dataType.EqualCase("timestamp") && propertyTypeName.EqualCase("timestamptz"))
{
return false;
}
return !properyTypeName.Equals(dataType, StringComparison.OrdinalIgnoreCase);
return !propertyTypeName.Equals(dataType, StringComparison.OrdinalIgnoreCase);
}
/// <summary>

View File

@@ -555,41 +555,41 @@ namespace ThingsGateway.SqlSugar
#endregion
#region Common Database Logic
string bindProperyTypeName = bindPropertyType.Name.ToLower();
string bindPropertyTypeName = bindPropertyType.Name.ToLower();
bool isEnum = bindPropertyType.IsEnum();
if (isEnum) { validPropertyType = CSharpDataType.@enum; }
switch (validPropertyType)
{
case CSharpDataType.@int:
CheckType(bind.IntThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName.IsContainsIn("int", "int32"))
CheckType(bind.IntThrow, bindPropertyTypeName, validPropertyName, propertyName);
if (bindPropertyTypeName.IsContainsIn("int", "int32"))
method = isNullableType ? getConvertInt32 : getInt32;
if (bindProperyTypeName.IsContainsIn("int64"))
if (bindPropertyTypeName.IsContainsIn("int64"))
method = null;
if (bindProperyTypeName.IsContainsIn("byte"))
if (bindPropertyTypeName.IsContainsIn("byte"))
method = isNullableType ? getConvertByte : getByte;
if (bindProperyTypeName.IsContainsIn("int16"))
if (bindPropertyTypeName.IsContainsIn("int16"))
method = isNullableType ? getConvertInt16 : getInt16;
if (bindProperyTypeName == "uint32" && this.Context.CurrentConnectionConfig.DbType.IsIn(DbType.MySql, DbType.MySqlConnector))
if (bindPropertyTypeName == "uint32" && this.Context.CurrentConnectionConfig.DbType.IsIn(DbType.MySql, DbType.MySqlConnector))
method = null;
if (bindProperyTypeName == "int16")
if (bindPropertyTypeName == "int16")
method = null;
break;
case CSharpDataType.@bool:
if (bindProperyTypeName == "bool" || bindProperyTypeName == "boolean")
if (bindPropertyTypeName == "bool" || bindPropertyTypeName == "boolean")
method = isNullableType ? getConvertBoolean : getBoolean;
break;
case CSharpDataType.@string:
if (this.Context.CurrentConnectionConfig.DbType != DbType.Oracle)
{
CheckType(bind.StringThrow, bindProperyTypeName, validPropertyName, propertyName);
CheckType(bind.StringThrow, bindPropertyTypeName, validPropertyName, propertyName);
}
method = getString;
if (bindProperyTypeName == "guid")
if (bindPropertyTypeName == "guid")
{
method = isNullableType ? getConvertStringGuid : getStringGuid;
}
else if (bindProperyTypeName == "xelement")
else if (bindPropertyTypeName == "xelement")
{
method = getXelement;
}
@@ -603,27 +603,27 @@ namespace ThingsGateway.SqlSugar
}
break;
case CSharpDataType.DateTime:
CheckType(bind.DateThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName == "datetime")
CheckType(bind.DateThrow, bindPropertyTypeName, validPropertyName, propertyName);
if (bindPropertyTypeName == "datetime")
method = isNullableType ? getConvertDateTime : getDateTime;
if (bindProperyTypeName == "datetime" && dbTypeName.Equals("time", StringComparison.CurrentCultureIgnoreCase))
if (bindPropertyTypeName == "datetime" && dbTypeName.Equals("time", StringComparison.CurrentCultureIgnoreCase))
method = isNullableType ? getConvertTime : getTime;
if (bindProperyTypeName == "datetimeoffset")
if (bindPropertyTypeName == "datetimeoffset")
method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
break;
case CSharpDataType.@decimal:
CheckType(bind.DecimalThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName == "decimal")
CheckType(bind.DecimalThrow, bindPropertyTypeName, validPropertyName, propertyName);
if (bindPropertyTypeName == "decimal")
method = isNullableType ? getConvertDecimal : getDecimal;
break;
case CSharpDataType.@float:
case CSharpDataType.@double:
CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName.IsIn("double", "single") && dbTypeName != "real")
CheckType(bind.DoubleThrow, bindPropertyTypeName, validPropertyName, propertyName);
if (bindPropertyTypeName.IsIn("double", "single") && dbTypeName != "real")
method = isNullableType ? getConvertDouble : getDouble;
else
method = isNullableType ? getConvertFloat : getFloat;
if (dbTypeName.Equals("float", StringComparison.CurrentCultureIgnoreCase) && isNullableType && bindProperyTypeName.Equals("single", StringComparison.CurrentCultureIgnoreCase))
if (dbTypeName.Equals("float", StringComparison.CurrentCultureIgnoreCase) && isNullableType && bindPropertyTypeName.Equals("single", StringComparison.CurrentCultureIgnoreCase))
{
method = getConvertDoubleToFloat;
}
@@ -635,35 +635,35 @@ namespace ThingsGateway.SqlSugar
{
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
}
if (bindProperyTypeName == "string")
if (bindPropertyTypeName == "string")
{
method = null;
}
break;
case CSharpDataType.Guid:
CheckType(bind.GuidThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName == "guid")
CheckType(bind.GuidThrow, bindPropertyTypeName, validPropertyName, propertyName);
if (bindPropertyTypeName == "guid")
method = isNullableType ? getConvertGuid : getGuid;
break;
case CSharpDataType.@byte:
if (bindProperyTypeName == "byte")
if (bindPropertyTypeName == "byte")
method = isNullableType ? getConvertByte : getByte;
break;
case CSharpDataType.@enum:
method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType);
break;
case CSharpDataType.@short:
CheckType(bind.ShortThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName == "int16" || bindProperyTypeName == "short")
CheckType(bind.ShortThrow, bindPropertyTypeName, validPropertyName, propertyName);
if (bindPropertyTypeName == "int16" || bindPropertyTypeName == "short")
method = isNullableType ? getConvertInt16 : getInt16;
break;
case CSharpDataType.@long:
if (bindProperyTypeName == "int64" || bindProperyTypeName == "long")
if (bindPropertyTypeName == "int64" || bindPropertyTypeName == "long")
method = isNullableType ? getConvertInt64 : getInt64;
break;
case CSharpDataType.DateTimeOffset:
method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
if (bindProperyTypeName == "datetime")
if (bindPropertyTypeName == "datetime")
method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate;
break;
case CSharpDataType.Single:
@@ -696,15 +696,15 @@ namespace ThingsGateway.SqlSugar
/// 检查类型
/// </summary>
/// <param name="invalidTypes">无效类型列表</param>
/// <param name="bindProperyTypeName">绑定属性类型名称</param>
/// <param name="bindPropertyTypeName">绑定属性类型名称</param>
/// <param name="validPropertyType">有效属性类型</param>
/// <param name="propertyName">属性名</param>
private void CheckType(List<string> invalidTypes, string bindProperyTypeName, string validPropertyType, string propertyName)
private void CheckType(List<string> invalidTypes, string bindPropertyTypeName, string validPropertyType, string propertyName)
{
var isAny = invalidTypes.Contains(bindProperyTypeName);
var isAny = invalidTypes.Contains(bindPropertyTypeName);
if (isAny)
{
throw new SqlSugarException(string.Format("{0} can't convert {1} to {2}", propertyName, validPropertyType, bindProperyTypeName));
throw new SqlSugarException(string.Format("{0} can't convert {1} to {2}", propertyName, validPropertyType, bindPropertyTypeName));
}
}
#endregion

View File

@@ -26,11 +26,11 @@ namespace ThingsGateway.SqlSugar
{
var type = MethodInfos.GetType().GetGenericArguments()[0];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.MethodInfos.GetType().GetMyMethod("Include", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this.MethodInfos, new object[] { exp, deleteNavOptions });
this.MethodInfos = obj;
return this;
@@ -46,11 +46,11 @@ namespace ThingsGateway.SqlSugar
{
var type = MethodInfos.GetType().GetGenericArguments()[1];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.MethodInfos.GetType().GetMyMethod("ThenInclude", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this.MethodInfos, new object[] { exp, deleteNavOptions });
this.MethodInfos = obj;
return this;

View File

@@ -6,7 +6,7 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 动态属性构建器
/// </summary>
public class DynamicProperyBuilder
public class DynamicPropertyBuilder
{
private bool IsCache = false;
public DynamicBuilder baseBuilder;
@@ -14,27 +14,27 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 创建新的构建器副本
/// </summary>
public static DynamicProperyBuilder CopyNew()
public static DynamicPropertyBuilder CopyNew()
{
return new DynamicProperyBuilder();
return new DynamicPropertyBuilder();
}
/// <summary>
/// 创建属性
/// </summary>
/// <param name="propertyName">属性名</param>
/// <param name="properyType">属性类型</param>
/// <param name="propertyType">属性类型</param>
/// <param name="column">列配置</param>
/// <param name="isSplitField">是否分表字段</param>
/// <param name="navigate">导航属性配置</param>
public DynamicProperyBuilder CreateProperty(string propertyName, Type properyType, SugarColumn column = null, bool isSplitField = false, Navigate navigate = null)
public DynamicPropertyBuilder CreateProperty(string propertyName, Type propertyType, SugarColumn column = null, bool isSplitField = false, Navigate navigate = null)
{
column ??= new SugarColumn() { ColumnName = propertyName };
var addItem = new PropertyMetadata
{
Name = propertyName,
Type = properyType,
Type = propertyType,
CustomAttributes = new List<CustomAttributeBuilder>() { baseBuilder.GetProperty(column) }
};
@@ -56,7 +56,7 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 设置是否缓存
/// </summary>
public DynamicProperyBuilder WithCache(bool isCache = true)
public DynamicPropertyBuilder WithCache(bool isCache = true)
{
IsCache = isCache;
return this;
@@ -94,7 +94,7 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 构建关联类型
/// </summary>
public Tuple<Type, Type> BuilderTypes(DynamicProperyBuilder dynamicBuilderB)
public Tuple<Type, Type> BuilderTypes(DynamicPropertyBuilder dynamicBuilderB)
{
if (IsCache)
{
@@ -113,7 +113,7 @@ namespace ThingsGateway.SqlSugar
}
}
private Tuple<Type, Type> GetBuilderTypes(DynamicProperyBuilder dynamicBuilderB)
private Tuple<Type, Type> GetBuilderTypes(DynamicPropertyBuilder dynamicBuilderB)
{
var typeBuilderA = EmitTool.CreateTypeBuilder(
baseBuilder.entityName,

View File

@@ -56,7 +56,7 @@ namespace ThingsGateway.SqlSugar
/// <param name="interfaces">接口类型数组</param>
/// <param name="splitTableAttribute">分表属性</param>
/// <returns>动态属性构建器</returns>
public DynamicProperyBuilder CreateClass(string entityName, SugarTable table = null, Type baseType = null, Type[] interfaces = null, SplitTableAttribute splitTableAttribute = null)
public DynamicPropertyBuilder CreateClass(string entityName, SugarTable table = null, Type baseType = null, Type[] interfaces = null, SplitTableAttribute splitTableAttribute = null)
{
this.baseType = baseType;
this.interfaces = interfaces;
@@ -70,7 +70,7 @@ namespace ThingsGateway.SqlSugar
{
this.entityAttr.Add(GetSplitEntityAttr(splitTableAttribute));
}
return new DynamicProperyBuilder() { baseBuilder = this };
return new DynamicPropertyBuilder() { baseBuilder = this };
}
/// <summary>

View File

@@ -15,7 +15,7 @@
{
// 获取父实体信息和父实体列表
var parentEntity = _ParentEntity;
var prentList = _ParentList.Cast<T>().ToList();
var parentList = _ParentList.Cast<T>().ToList();
// 获取导航属性信息
var parentNavigateProperty = parentEntity.Columns.FirstOrDefault(it => it.PropertyName == name);
@@ -37,7 +37,7 @@
// 删除父表数据(如果尚未删除)
if (!_IsDeletedParant)
SetContext(() => this._Context.Deleteable(prentList)
SetContext(() => this._Context.Deleteable(parentList)
.EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent == true, _RootOptions?.DiffLogBizData)
.ExecuteCommand());

View File

@@ -75,11 +75,11 @@ namespace ThingsGateway.SqlSugar
DeleteNavMethodInfo result = new DeleteNavMethodInfo();
result.Context = deleteNavProvider._Context;
var entityInfo = result.Context.EntityMaintenance.GetEntityInfo<T>();
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.GetType().GetMyMethod("Include", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this, new object[] { exp, deleteNavOptions });
result.MethodInfos = obj;
return result;

View File

@@ -35,11 +35,11 @@ namespace ThingsGateway.SqlSugar
InsertNavMethodInfo result = new InsertNavMethodInfo();
result.Context = insertNavProvider._Context;
var entityInfo = result.Context.EntityMaintenance.GetEntityInfo<T>();
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.GetType().GetMyMethod("Include", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this, new object[] { exp, insertNavOptions });
result.MethodInfos = obj;
return result;

View File

@@ -154,11 +154,11 @@ namespace ThingsGateway.SqlSugar
UpdateNavMethodInfo result = new UpdateNavMethodInfo();
result.Context = UpdateNavProvider._Context;
var entityInfo = result.Context.EntityMaintenance.GetEntityInfo<T>();
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.GetType().GetMyMethod("Include", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this, new object[] { exp, updateNavOptions });
result.MethodInfos = obj;
return result;

View File

@@ -11,9 +11,9 @@ namespace ThingsGateway.SqlSugar
switch (this.context.CurrentConnectionConfig.DbType)
{
case DbType.MySql:
var result = new MySqlFastBuilder();
result.CharacterSet = this.CharacterSet;
return result;
var result1 = new MySqlFastBuilder();
result1.CharacterSet = this.CharacterSet;
return result1;
case DbType.SqlServer:
var result2 = new SqlServerFastBuilder();
result2.DbFastestProperties.IsOffIdentity = this.IsOffIdentity;
@@ -44,10 +44,10 @@ namespace ThingsGateway.SqlSugar
className = $"{SugarConst.StartName}SqlSugar.{this.context.CurrentConnectionConfig.DbType.ToString().Replace("Native", "")}FastBuilder";
break;
}
var reslut = InstanceFactory.CreateInstance<IFastBuilder>(className);
reslut.CharacterSet = this.CharacterSet;
reslut.FastEntityInfo = this.entityInfo;
return reslut;
var result = InstanceFactory.CreateInstance<IFastBuilder>(className);
result.CharacterSet = this.CharacterSet;
result.FastEntityInfo = this.entityInfo;
return result;
}
/// <summary>将实体列表转换为DataTable</summary>

View File

@@ -78,16 +78,16 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 异步执行插入并返回标识
/// </summary>
public Task<int> ExecuteReturnIdentityAsync()
public Task<int> ExecuteReturnIdentityAsync()
{
if (Context == null) return Task.FromResult( 0);
if (Context == null) return Task.FromResult(0);
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var result = inertable.GetType().GetMyMethod("ExecuteReturnIdentityAsync", 0).Invoke(inertable, Array.Empty<object>());
return Task.FromResult((int)result);
}
public Task<long> ExecuteReturnBigIdentityAsync()
public Task<long> ExecuteReturnBigIdentityAsync()
{
if (Context == null) return Task.FromResult( (long)0);
if (Context == null) return Task.FromResult((long)0);
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var result = inertable.GetType().GetMyMethod("ExecuteReturnBigIdentityAsync", 0).Invoke(inertable, Array.Empty<object>());
return Task.FromResult((long)result);

View File

@@ -23,11 +23,11 @@ namespace ThingsGateway.SqlSugar
{
var type = MethodInfos.GetType().GetGenericArguments()[0];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.MethodInfos.GetType().GetMyMethod("Include", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this.MethodInfos, new object[] { exp, insertNavOptions });
this.MethodInfos = obj;
return this;
@@ -40,11 +40,11 @@ namespace ThingsGateway.SqlSugar
{
var type = MethodInfos.GetType().GetGenericArguments()[1];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.MethodInfos.GetType().GetMyMethod("ThenInclude", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this.MethodInfos, new object[] { exp, insertNavOptions });
this.MethodInfos = obj;
return this;

View File

@@ -2,20 +2,56 @@
namespace ThingsGateway.SqlSugar
{
/// <summary>
/// 导航属性追加信息,包含映射关系、追加属性和结果集合。
/// </summary>
internal class AppendNavInfo
{
/// <summary>
/// 导航属性与列信息的映射字典。
/// </summary>
public Dictionary<string, MappingNavColumnInfo> MappingNavProperties { get; set; } = new Dictionary<string, MappingNavColumnInfo>();
/// <summary>
/// 需要追加的属性字典。
/// </summary>
public Dictionary<string, string> AppendProperties { get; set; } = new Dictionary<string, string>();
/// <summary>
/// 追加导航属性的结果集合。
/// </summary>
public List<AppendNavResult> Result { get; set; } = new List<AppendNavResult>();
}
/// <summary>
/// 追加导航属性的结果,存储结果字典。
/// </summary>
internal class AppendNavResult
{
/// <summary>
/// 结果字典。
/// </summary>
public Dictionary<string, object> result = new Dictionary<string, object>();
}
/// <summary>
/// 导航属性列的映射信息。
/// </summary>
internal class MappingNavColumnInfo
{
/// <summary>
/// 表达式列表。
/// </summary>
public List<Expression> ExpressionList { get; set; }
/// <summary>
/// 当前属性名称。
/// </summary>
public string Name { get; set; }
/// <summary>
/// 父级属性名称。
/// </summary>
public string ParentName { get; set; }
}
}

View File

@@ -1,10 +1,28 @@
namespace ThingsGateway.SqlSugar
{
/// <summary>
/// 查询追加列信息,用于描述在查询中动态追加的列。
/// </summary>
internal class QueryableAppendColumn
{
/// <summary>
/// 列的别名。
/// </summary>
public string AsName { get; set; }
/// <summary>
/// 列的索引位置。
/// </summary>
public int Index { get; set; }
/// <summary>
/// 列的值。
/// </summary>
public object Value { get; set; }
/// <summary>
/// 列的名称。
/// </summary>
public string Name { get; set; }
}
}

View File

@@ -2,13 +2,39 @@
namespace ThingsGateway.SqlSugar
{
/// <summary>
/// 查询格式化信息,用于描述类型、格式、属性和方法等相关信息。
/// </summary>
internal class QueryableFormat
{
/// <summary>
/// 关联的类型。
/// </summary>
public Type Type { get; set; }
/// <summary>
/// 类型的字符串表示。
/// </summary>
public string TypeString { get; set; }
/// <summary>
/// 格式化字符串。
/// </summary>
public string Format { get; set; }
/// <summary>
/// 属性名称。
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// 方法名称。
/// </summary>
public string MethodName { get; set; }
/// <summary>
/// 方法信息。
/// </summary>
public MethodInfo MethodInfo { get; set; }
}
}

View File

@@ -1,17 +1,58 @@
namespace ThingsGateway.SqlSugar
{
/// <summary>
/// SQL 信息类,封装了查询相关的各种参数和表达式。
/// </summary>
internal class SqlInfo
{
/// <summary>
/// 是否为导航属性查询。
/// </summary>
public bool IsSelectNav { get; set; }
/// <summary>
/// 查询返回的最大记录数Take
/// </summary>
public int? Take { get; set; }
/// <summary>
/// 跳过的记录数Skip
/// </summary>
public int? Skip { get; set; }
/// <summary>
/// Where 条件字符串。
/// </summary>
public string WhereString { get; set; }
/// <summary>
/// OrderBy 排序字符串。
/// </summary>
public string OrderByString { get; set; }
/// <summary>
/// Select 查询字段字符串。
/// </summary>
public string SelectString { get; set; }
/// <summary>
/// 查询参数集合。
/// </summary>
public List<SugarParameter> Parameters { get; set; }
/// <summary>
/// 映射字段表达式集合。
/// </summary>
public List<MappingFieldsExpression> MappingExpressions { get; set; }
/// <summary>
/// 表的短名称(别名)。
/// </summary>
public string TableShortName { get; set; }
/// <summary>
/// 分表处理委托。
/// </summary>
public Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> SplitTable { get; set; }
}
}

View File

@@ -1,8 +1,18 @@
namespace ThingsGateway.SqlSugar
{
/// <summary>
/// 子查询默认返回对象,包含主键和索引信息。
/// </summary>
internal class SubQueryToListDefaultT
{
public object id { get; set; }
public object sugarIndex { get; set; }
/// <summary>
/// 主键值。
/// </summary>
public object Id { get; set; }
/// <summary>
/// 索引值。
/// </summary>
public object SugarIndex { get; set; }
}
}

View File

@@ -53,14 +53,14 @@ namespace ThingsGateway.SqlSugar
{
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression2")
.First();
List<Expression> parametres = new List<Expression>();
List<Expression> parameters = new List<Expression>();
List<Type> types = new List<Type>();
var entityInfo = this.EntityInfo;
method = GetIncludesByNameStringMethod(types, navMemberName, method, parametres, entityInfo);
method = GetIncludesByNameStringMethod(types, navMemberName, method, parameters, entityInfo);
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parametres, entityInfo2);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parameters, entityInfo2);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parameters.Cast<object>().ToArray());
return this;
}
/// <summary>
@@ -70,16 +70,16 @@ namespace ThingsGateway.SqlSugar
{
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression3")
.First();
List<Expression> parametres = new List<Expression>();
List<Expression> parameters = new List<Expression>();
List<Type> types = new List<Type>();
var entityInfo = this.EntityInfo;
method = GetIncludesByNameStringMethod(types, navMemberName, method, parametres, entityInfo);
method = GetIncludesByNameStringMethod(types, navMemberName, method, parameters, entityInfo);
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parametres, entityInfo2);
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parameters, entityInfo2);
var entityInfo3 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parametres, entityInfo3);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parameters, entityInfo3);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parameters.Cast<object>().ToArray());
return this;
}
/// <summary>
@@ -89,18 +89,18 @@ namespace ThingsGateway.SqlSugar
{
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression4")
.First();
List<Expression> parametres = new List<Expression>();
List<Expression> parameters = new List<Expression>();
List<Type> types = new List<Type>();
var entityInfo = this.EntityInfo;
method = GetIncludesByNameStringMethod(types, navMemberName, method, parametres, entityInfo);
method = GetIncludesByNameStringMethod(types, navMemberName, method, parameters, entityInfo);
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parametres, entityInfo2);
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parameters, entityInfo2);
var entityInfo3 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parametres, entityInfo3);
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parameters, entityInfo3);
var entityInfo4 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName4, method, parametres, entityInfo4);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
method = GetIncludesByNameStringMethod(types, thenNavMemberName4, method, parameters, entityInfo4);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parameters.Cast<object>().ToArray());
return this;
}
/// <summary>
@@ -110,29 +110,29 @@ namespace ThingsGateway.SqlSugar
{
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression5")
.First();
List<Expression> parametres = new List<Expression>();
List<Expression> parameters = new List<Expression>();
List<Type> types = new List<Type>();
var entityInfo = this.EntityInfo;
method = GetIncludesByNameStringMethod(types, navMemberName, method, parametres, entityInfo);
method = GetIncludesByNameStringMethod(types, navMemberName, method, parameters, entityInfo);
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parametres, entityInfo2);
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parameters, entityInfo2);
var entityInfo3 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parametres, entityInfo3);
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parameters, entityInfo3);
var entityInfo4 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName4, method, parametres, entityInfo4);
method = GetIncludesByNameStringMethod(types, thenNavMemberName4, method, parameters, entityInfo4);
var entityInfo5 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName5, method, parametres, entityInfo5);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
method = GetIncludesByNameStringMethod(types, thenNavMemberName5, method, parameters, entityInfo5);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parameters.Cast<object>().ToArray());
return this;
}
/// <summary>
/// 获取通过字符串名称包含关联实体的方法信息
/// </summary>
private static MethodInfo GetIncludesByNameStringMethod(List<Type> types, string navMemberName, MethodInfo method, List<Expression> parametres, EntityInfo entityInfo)
private static MethodInfo GetIncludesByNameStringMethod(List<Type> types, string navMemberName, MethodInfo method, List<Expression> parameters, EntityInfo entityInfo)
{
var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
parametres.AddRange(GetIncludesByNameStringParameters(entityInfo.Type, navFirst));
parameters.AddRange(GetIncludesByNameStringParameters(entityInfo.Type, navFirst));
if (navFirst.PropertyInfo.PropertyType.FullName.IsCollectionsList())
{
types.Add(navFirst.PropertyInfo.PropertyType.GetGenericArguments()[0]);
@@ -157,17 +157,17 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private static List<Expression> GetIncludesByNameStringParameters(Type type, EntityColumnInfo item)
{
var parametres = new List<Expression> { };
var parameters = new List<Expression> { };
Check.ExceptionEasy(item == null, "\r\nThe \"IncludesByNameString\" method encountered an error. The navigation object does not exist. Please check the parameters and navigation configuration.", "IncludesByNameString方法出错导航对象不存在请检查参数和导航配置");
var properyType = item.PropertyInfo.PropertyType;
var properyItemType = properyType;
if (properyType.FullName.IsCollectionsList())
var propertyType = item.PropertyInfo.PropertyType;
var propertyItemType = propertyType;
if (propertyType.FullName.IsCollectionsList())
{
properyItemType = properyType.GetGenericArguments()[0];
propertyItemType = propertyType.GetGenericArguments()[0];
}
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(type, item.PropertyName, properyType);
parametres.Add(exp);
return parametres;
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(type, item.PropertyName, propertyType);
parameters.Add(exp);
return parameters;
}
/// <summary>
@@ -178,16 +178,16 @@ namespace ThingsGateway.SqlSugar
var navs = this.EntityInfo.Columns.Where(it => it.Navigat != null && it.PropertyName.EqualCase(navMemberName)).ToList();
foreach (var item in navs)
{
var properyType = item.PropertyInfo.PropertyType;
var properyItemType = properyType;
if (properyType.FullName.IsCollectionsList())
var propertyType = item.PropertyInfo.PropertyType;
var propertyItemType = propertyType;
if (propertyType.FullName.IsCollectionsList())
{
properyItemType = properyType.GetGenericArguments()[0];
propertyItemType = propertyType.GetGenericArguments()[0];
}
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(typeof(T), item.PropertyName, properyType);
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(typeof(T), item.PropertyName, propertyType);
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression")
.First()
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
method.Invoke(this, new object[] { exp });
}
return this;
@@ -195,32 +195,32 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 包含所有第一层关联实体(可忽略指定属性)
/// </summary>
public ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignoreProperyNameList)
public ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignorePropertyNameList)
{
var navs = this.EntityInfo.Columns.Where(it => it.Navigat != null).ToList();
foreach (var item in navs)
{
if (ignoreProperyNameList?.Any(z => z.EqualCase(item.PropertyName)) == true)
if (ignorePropertyNameList?.Any(z => z.EqualCase(item.PropertyName)) == true)
{
//future
}
else
{
var properyType = item.PropertyInfo.PropertyType;
var properyItemType = properyType;
if (properyType.FullName.IsCollectionsList())
var propertyType = item.PropertyInfo.PropertyType;
var propertyItemType = propertyType;
if (propertyType.FullName.IsCollectionsList())
{
properyItemType = properyType.GetGenericArguments()[0];
propertyItemType = propertyType.GetGenericArguments()[0];
}
var shortName = "it";
if (this.QueryBuilder.TableShortName.HasValue())
{
shortName = this.QueryBuilder.TableShortName;
}
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(typeof(T), item.PropertyName, properyType, shortName);
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(typeof(T), item.PropertyName, propertyType, shortName);
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression")
.First()
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
method.Invoke(this, new object[] { exp });
}
}
@@ -229,7 +229,7 @@ namespace ThingsGateway.SqlSugar
/// <summary>
/// 包含所有第二层关联实体(可忽略指定属性)
/// </summary>
public ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression, params string[] ignoreProperyNameList)
public ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression, params string[] ignorePropertyNameList)
{
//this.Includes(expression);
var type = typeof(TReturn1);
@@ -240,22 +240,22 @@ namespace ThingsGateway.SqlSugar
var navs = this.Context.EntityMaintenance.GetEntityInfo(type).Columns.Where(it => it.Navigat != null).ToList();
foreach (var item in navs)
{
if (ignoreProperyNameList?.Any(z => z.EqualCase(item.PropertyName)) == true)
if (ignorePropertyNameList?.Any(z => z.EqualCase(item.PropertyName)) == true)
{
//future
}
else
{
var properyType = item.PropertyInfo.PropertyType;
var properyItemType = properyType;
if (properyType.FullName.IsCollectionsList())
var propertyType = item.PropertyInfo.PropertyType;
var propertyItemType = propertyType;
if (propertyType.FullName.IsCollectionsList())
{
properyItemType = properyType.GetGenericArguments()[0];
propertyItemType = propertyType.GetGenericArguments()[0];
}
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(type, item.PropertyName, properyType);
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(type, item.PropertyName, propertyType);
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression2")
.First()
.MakeGenericMethod(type, properyItemType);
.MakeGenericMethod(type, propertyItemType);
method.Invoke(this, new object[] { expression, exp });
}
}

View File

@@ -9,9 +9,9 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR1 = selectR1;
navigat.Expressions = expressions;
navigat.Context = this.Context;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
@@ -26,11 +26,11 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
navigat.Expressions = expressions;
@@ -45,13 +45,13 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
navigat.Expressions = expressions;
@@ -66,15 +66,15 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR4 = it => it.Select<TReturn4>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR4 = SelectR4;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.SelectR4 = selectR4;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -89,17 +89,17 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4, TReturn5>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR5 = it => it.Select<TReturn5>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR4 = it => it.Select<TReturn4>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR5 = it => it.Select<TReturn5>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR4 = SelectR4;
navigat.SelectR5 = SelectR5;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.SelectR4 = selectR4;
navigat.SelectR5 = selectR5;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -194,9 +194,9 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR1 = selectR1;
navigat.Expressions = expressions;
navigat.Context = this.Context;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
@@ -211,11 +211,11 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -230,13 +230,13 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -251,15 +251,15 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR4 = it => it.Select<TReturn4>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR4 = SelectR4;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.SelectR4 = selectR4;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -274,17 +274,17 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4, TReturn5>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR5 = it => it.Select<TReturn5>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR4 = it => it.Select<TReturn4>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR5 = it => it.Select<TReturn5>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR4 = SelectR4;
navigat.SelectR5 = SelectR5;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.SelectR4 = selectR4;
navigat.SelectR5 = selectR5;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -299,19 +299,19 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4, TReturn5, TReturn6>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR5 = it => it.Select<TReturn5>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR6 = it => it.Select<TReturn6>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR4 = it => it.Select<TReturn4>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR5 = it => it.Select<TReturn5>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR6 = it => it.Select<TReturn6>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR4 = SelectR4;
navigat.SelectR5 = SelectR5;
navigat.SelectR6 = SelectR6;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.SelectR4 = selectR4;
navigat.SelectR5 = selectR5;
navigat.SelectR6 = selectR6;
navigat.Expressions = expressions;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
@@ -326,21 +326,21 @@ namespace ThingsGateway.SqlSugar
/// </summary>
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4, TReturn5, TReturn6, TReturn7>(SqlSugarProvider context, params Expression[] expressions)
{
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR5 = it => it.Select<TReturn5>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR6 = it => it.Select<TReturn6>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> SelectR7 = it => it.Select<TReturn7>().ToList().Select(x => x as object).ToList();
Func<ISugarQueryable<object>, List<object>> selectR1 = it => it.Select<TReturn1>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR2 = it => it.Select<TReturn2>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR3 = it => it.Select<TReturn3>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR4 = it => it.Select<TReturn4>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR5 = it => it.Select<TReturn5>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR6 = it => it.Select<TReturn6>().ToList().Cast<object>().ToList();
Func<ISugarQueryable<object>, List<object>> selectR7 = it => it.Select<TReturn7>().ToList().Cast<object>().ToList();
var navigat = new NavigatManager<T>();
navigat.SelectR1 = SelectR1;
navigat.SelectR2 = SelectR2;
navigat.SelectR3 = SelectR3;
navigat.SelectR4 = SelectR4;
navigat.SelectR5 = SelectR5;
navigat.SelectR6 = SelectR6;
navigat.SelectR7 = SelectR7;
navigat.SelectR1 = selectR1;
navigat.SelectR2 = selectR2;
navigat.SelectR3 = selectR3;
navigat.SelectR4 = selectR4;
navigat.SelectR5 = selectR5;
navigat.SelectR6 = selectR6;
navigat.SelectR7 = selectR7;
navigat.Expressions = expressions;
navigat.QueryBuilder = this.QueryBuilder;
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;

View File

@@ -22,34 +22,13 @@ namespace ThingsGateway.SqlSugar
/// </summary>
public EntityInfo RootEntity { get; set; }
/// <summary>
/// 获取映射字段信息
/// </summary>
/// <param name="thisField">当前字段表达式</param>
/// <param name="mappingField">映射字段表达式</param>
/// <returns>映射字段信息</returns>
public MappingFieldsInfo GetMappings(Expression thisField, Expression mappingField)
{
MappingFieldsInfo mappingFields = new MappingFieldsInfo();
var pkName = "";
if ((mappingField as LambdaExpression).Body is UnaryExpression)
{
pkName = (((mappingField as LambdaExpression).Body as UnaryExpression).Operand as MemberExpression).Member.Name;
}
else
{
pkName = ((mappingField as LambdaExpression).Body as MemberExpression).Member.Name;
}
return mappingFields;
}
/// <summary>
/// 获取映射SQL条件
/// </summary>
/// <param name="list">对象列表</param>
/// <param name="mappingFieldsExpressions">映射字段表达式列表</param>
/// <returns>条件模型列表</returns>
public List<IConditionalModel> GetMppingSql(List<object> list, List<MappingFieldsExpression> mappingFieldsExpressions)
public List<IConditionalModel> GetMappingSql(List<object> list, List<MappingFieldsExpression> mappingFieldsExpressions)
{
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
foreach (var model in list)
@@ -113,14 +92,7 @@ namespace ThingsGateway.SqlSugar
{
//var expable =Expressionable.Create<object>();
List<object> setList = GetSetList(item, list, mappingFieldsExpressions);
//navColumnInfo.PropertyInfo.SetValue();
var instance = Activator.CreateInstance(navColumnInfo.PropertyInfo.PropertyType, true);
var ilist = instance as IList;
foreach (var value in setList)
{
navColumnInfo.PropertyInfo.SetValue(item, value);
}
navColumnInfo.PropertyInfo.SetValue(item, setList.LastOrDefault());
}
}
/// <summary>

View File

@@ -21,7 +21,7 @@ namespace ThingsGateway.SqlSugar
includeQueryable.Select(GetGroupSelect(typeof(T), queryableProvider.Context, queryableProvider.QueryBuilder));
includeQueryable.QueryBuilder.NoCheckInclude = true;
var mappingColumn = GetMappingColumn(expression);
MegerList(result, includeQueryable.ToList(), sqlfuncQueryable.Context, mappingColumn);
MergeList(result, includeQueryable.ToList(), sqlfuncQueryable.Context, mappingColumn);
}
else if (isSqlFunc)
{
@@ -107,7 +107,7 @@ namespace ThingsGateway.SqlSugar
var queryable = queryableProvider.Select(selector).Clone();
queryable.QueryBuilder.NoCheckInclude = true;
var includeList = queryable.ToList();
MegerList(result, includeList, sqlfuncQueryable.Context, mappingColumn);
MergeList(result, includeList, sqlfuncQueryable.Context, mappingColumn);
return result;
}
@@ -178,7 +178,7 @@ namespace ThingsGateway.SqlSugar
return columns;
}
private static void MegerList<TResult, T>(List<TResult> result, List<T> includeList, SqlSugarProvider context, List<NavMappingColumn> navMappingColumns)
private static void MergeList<TResult, T>(List<TResult> result, List<T> includeList, SqlSugarProvider context, List<NavMappingColumn> navMappingColumns)
{
if (result.Count != includeList.Count) return;
var columns = context.EntityMaintenance.GetEntityInfo<T>().Columns;
@@ -338,8 +338,8 @@ namespace ThingsGateway.SqlSugar
private static bool isGroup<T, TResult>(Expression<Func<T, TResult>> expression, QueryableProvider<T> queryableProvider)
{
var isGroup = queryableProvider.QueryBuilder.GetGroupByString.HasValue();
return isGroup;
var group = queryableProvider.QueryBuilder.GetGroupByString.HasValue();
return group;
}
internal class NavMappingColumn

View File

@@ -151,7 +151,7 @@ namespace ThingsGateway.SqlSugar
var listItemEntity = this.Context.EntityMaintenance.GetEntityInfo(listItemType);
var listPkColumn = listItemEntity.Columns.Where(it => it.IsPrimarykey).FirstOrDefault();
var navObjectName = memberExpression.Member.Name;
var navObjectNamePropety = listItemType.GetProperty(navObjectName);
var navObjectNameProperty = listItemType.GetProperty(navObjectName);
var navObjectNameColumnInfo = listItemEntity.Columns.First(it => it.PropertyName == navObjectName);
Check.ExceptionEasy(navObjectNameColumnInfo.Navigat == null, $"{navObjectName} not [Navigat(..)] ", $"{navObjectName} 没有导航特性 [Navigat(..)] ");
@@ -161,35 +161,35 @@ namespace ThingsGateway.SqlSugar
{
this.Context.Utilities.PageEach(list, 5000, pageList =>
{
OneToOne(pageList, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
OneToOne(pageList, selector, listItemEntity, navObjectNameProperty, navObjectNameColumnInfo);
});
}
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.OneToMany)
{
this.Context.Utilities.PageEach(list, 5000, pageList =>
{
OneToMany(pageList, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
OneToMany(pageList, selector, listItemEntity, navObjectNameProperty, navObjectNameColumnInfo);
});
}
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.ManyToOne)
{
this.Context.Utilities.PageEach(list, 5000, pageList =>
{
OneToOne(pageList, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
OneToOne(pageList, selector, listItemEntity, navObjectNameProperty, navObjectNameColumnInfo);
});
}
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.Dynamic)
{
this.Context.Utilities.PageEach(list, 100, pageList =>
{
Dynamic(pageList, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo, expression);
Dynamic(pageList, selector, listItemEntity, navObjectNameProperty, navObjectNameColumnInfo, expression);
});
}
else
{
this.Context.Utilities.PageEach(list, 100, pageList =>
{
ManyToMany(pageList, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
ManyToMany(pageList, selector, listItemEntity, navObjectNameProperty, navObjectNameColumnInfo);
});
}
}
@@ -211,7 +211,7 @@ namespace ThingsGateway.SqlSugar
return expressions;
}
private void ManyToMany(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo)
private void ManyToMany(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNameProperty, EntityColumnInfo navObjectNameColumnInfo)
{
var bEntity = navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments()[0];
var bEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(bEntity);
@@ -275,9 +275,9 @@ namespace ThingsGateway.SqlSugar
{
foreach (var listItem in list)
{
if (navObjectNamePropety.GetValue(listItem) == null)
if (navObjectNameProperty.GetValue(listItem) == null)
{
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
var instance = Activator.CreateInstance(navObjectNameProperty.PropertyType, true);
var ilist = instance as IList;
foreach (var bInfo in bList)
{
@@ -301,13 +301,13 @@ namespace ThingsGateway.SqlSugar
if (sql.Skip != null || sql.Take != null)
{
var instanceCast = (instance as IList);
var newinstance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true) as IList;
var newinstance = Activator.CreateInstance(navObjectNameProperty.PropertyType, true) as IList;
SkipTakeIList(sql, instanceCast, newinstance);
navObjectNamePropety.SetValue(listItem, newinstance);
navObjectNameProperty.SetValue(listItem, newinstance);
}
else
{
navObjectNamePropety.SetValue(listItem, instance);
navObjectNameProperty.SetValue(listItem, instance);
}
}
}
@@ -317,10 +317,10 @@ namespace ThingsGateway.SqlSugar
{
foreach (var listItem in list)
{
if (navObjectNamePropety.GetValue(listItem) == null)
if (navObjectNameProperty.GetValue(listItem) == null)
{
var newinstance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true) as IList;
navObjectNamePropety.SetValue(listItem, newinstance);
var newinstance = Activator.CreateInstance(navObjectNameProperty.PropertyType, true) as IList;
navObjectNameProperty.SetValue(listItem, newinstance);
}
}
}
@@ -345,11 +345,11 @@ namespace ThingsGateway.SqlSugar
}
}
private void OneToOne(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo)
private void OneToOne(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNameProperty, EntityColumnInfo navObjectNameColumnInfo)
{
var navColumn = listItemEntity.Columns.FirstOrDefault(it => it.PropertyName == navObjectNameColumnInfo.Navigat.Name);
Check.ExceptionEasy(navColumn == null, "OneToOne navigation configuration error", $"OneToOne导航配置错误 实体{listItemEntity.EntityName} 不存在{navObjectNameColumnInfo.Navigat.Name}");
var navType = navObjectNamePropety.PropertyType;
var navType = navObjectNameProperty.PropertyType;
var db = this.Context;
db = GetCrossDatabase(db, navType);
var navEntityInfo = db.EntityMaintenance.GetEntityInfo(navType);
@@ -363,7 +363,7 @@ namespace ThingsGateway.SqlSugar
}
if (navPkColumn == null && navType.FullName.IsCollectionsList())
{
Check.ExceptionEasy($"{navObjectNamePropety.Name} type error ", $"一对一不能是List对象 {navObjectNamePropety.Name} ");
Check.ExceptionEasy($"{navObjectNameProperty.Name} type error ", $"一对一不能是List对象 {navObjectNameProperty.Name} ");
}
List<object> ids = null;
var isOwnsOneProperty = IsOwnsOneProperty(listItemEntity, navObjectNameColumnInfo);
@@ -408,14 +408,14 @@ namespace ThingsGateway.SqlSugar
{
foreach (var item in list)
{
var firstObj = navObjectNamePropety.GetValue(item);
var firstObj = navObjectNameProperty.GetValue(item);
if (OneToOneGlobalInstanceRegistry.IsNavigationInitializerCreated(firstObj))
{
navObjectNamePropety.SetValue(item, null);
navObjectNameProperty.SetValue(item, null);
}
}
}
if (list.Count != 0 && navObjectNamePropety.GetValue(list.First()) == null)
if (list.Count != 0 && navObjectNameProperty.GetValue(list.First()) == null)
{
var sqlObj = GetWhereSql(db, navObjectNameColumnInfo.Navigat.Name);
if (sqlObj.SelectString == null)
@@ -451,9 +451,9 @@ namespace ThingsGateway.SqlSugar
// var setValue = navList.FirstOrDefault(x => navPkColumn.PropertyInfo.GetValue(x).ObjToString() == navColumn.PropertyInfo.GetValue(item).ObjToString());
if (navObjectNamePropety.GetValue(item.l) == null)
if (navObjectNameProperty.GetValue(item.l) == null)
{
navObjectNamePropety.SetValue(item.l, item.n);
navObjectNameProperty.SetValue(item.l, item.n);
}
else
{
@@ -483,9 +483,9 @@ namespace ThingsGateway.SqlSugar
// var setValue = navList.FirstOrDefault(x => navPkColumn.PropertyInfo.GetValue(x).ObjToString() == navColumn.PropertyInfo.GetValue(item).ObjToString());
if (navObjectNamePropety.GetValue(item.l) == null)
if (navObjectNameProperty.GetValue(item.l) == null)
{
navObjectNamePropety.SetValue(item.l, item.n);
navObjectNameProperty.SetValue(item.l, item.n);
}
else
{
@@ -512,9 +512,9 @@ namespace ThingsGateway.SqlSugar
// var setValue = navList.FirstOrDefault(x => navPkColumn.PropertyInfo.GetValue(x).ObjToString() == navColumn.PropertyInfo.GetValue(item).ObjToString());
if (navObjectNamePropety.GetValue(item.l) == null)
if (navObjectNameProperty.GetValue(item.l) == null)
{
navObjectNamePropety.SetValue(item.l, item.n);
navObjectNameProperty.SetValue(item.l, item.n);
}
else
{
@@ -526,9 +526,9 @@ namespace ThingsGateway.SqlSugar
}
}
private void OneToMany(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo)
private void OneToMany(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNameProperty, EntityColumnInfo navObjectNameColumnInfo)
{
Check.ExceptionEasy(navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments().Length == 0, navObjectNamePropety?.Name + "Navigation configuration error one to many should be List<T>", navObjectNamePropety?.Name + "导航配置错误一对多应该是List<T>");
Check.ExceptionEasy(navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments().Length == 0, navObjectNameProperty?.Name + "Navigation configuration error one to many should be List<T>", navObjectNameProperty?.Name + "导航配置错误一对多应该是List<T>");
var navEntity = navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments()[0];
var navEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(navEntity);
@@ -537,7 +537,7 @@ namespace ThingsGateway.SqlSugar
childDb.InitMappingInfo(navEntityInfo.Type);
var navColumn = navEntityInfo.Columns.FirstOrDefault(it => it.PropertyName == navObjectNameColumnInfo.Navigat.Name);
Check.ExceptionEasy(navColumn == null, $"{navEntityInfo.EntityName} not found {navObjectNameColumnInfo.Navigat.Name} ", $"实体 {navEntityInfo.EntityName} 未找到导航配置列 {navObjectNameColumnInfo.Navigat.Name} ");
//var navType = navObjectNamePropety.PropertyType;
//var navType = navObjectNameProperty.PropertyType;
var listItemPkColumn = listItemEntity.Columns.Where(it => it.IsPrimarykey).FirstOrDefault();
Check.ExceptionEasy(listItemPkColumn == null && navObjectNameColumnInfo.Navigat.Name2 == null, listItemEntity.EntityName + " not primary key", listItemEntity.EntityName + "没有主键");
if (navObjectNameColumnInfo.Navigat.Name2.HasValue())
@@ -564,7 +564,7 @@ namespace ThingsGateway.SqlSugar
}));
var sqlObj = GetWhereSql(childDb, navObjectNameColumnInfo.Navigat.Name);
if (list.Count != 0 && navObjectNamePropety.GetValue(list.First()) == null)
if (list.Count != 0 && navObjectNameProperty.GetValue(list.First()) == null)
{
if (sqlObj.SelectString == null)
{
@@ -610,21 +610,21 @@ namespace ThingsGateway.SqlSugar
else
{
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
var instance = Activator.CreateInstance(navObjectNameProperty.PropertyType, true);
var ilist = instance as IList;
foreach (var value in itemSelectList.ToList())
{
ilist.Add(value);
}
navObjectNamePropety.SetValue(item.Key, instance);
navObjectNameProperty.SetValue(item.Key, instance);
}
}
foreach (var item in list)
{
if (navObjectNamePropety.GetValue(item) == null)
if (navObjectNameProperty.GetValue(item) == null)
{
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
navObjectNamePropety.SetValue(item, instance);
var instance = Activator.CreateInstance(navObjectNameProperty.PropertyType, true);
navObjectNameProperty.SetValue(item, instance);
}
}
}
@@ -633,19 +633,19 @@ namespace ThingsGateway.SqlSugar
//No navigation data set new List()
foreach (var item in list)
{
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
navObjectNamePropety.SetValue(item, instance);
var instance = Activator.CreateInstance(navObjectNameProperty.PropertyType, true);
navObjectNameProperty.SetValue(item, instance);
}
}
}
}
private void Dynamic(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo, Expression expression)
private void Dynamic(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNameProperty, EntityColumnInfo navObjectNameColumnInfo, Expression expression)
{
var args = navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments();
if (args.Length == 0)
{
DynamicOneToOne(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo, expression);
DynamicOneToOne(list, selector, listItemEntity, navObjectNameProperty, navObjectNameColumnInfo, expression);
return;
}
var navEntity = args[0];
@@ -665,13 +665,13 @@ namespace ThingsGateway.SqlSugar
}
}
Check.ExceptionEasy(sqlObj.MappingExpressions.IsNullOrEmpty(), $"{expression} error,dynamic need MappingField ,Demo: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())", $"{expression} 解析出错,自定义映射需要 MappingField ,例子: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())");
if (list.Count != 0 && navObjectNamePropety.GetValue(list.First()) == null)
if (list.Count != 0 && navObjectNameProperty.GetValue(list.First()) == null)
{
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
helper.Context = childDb;
helper.NavEntity = navEntityInfo;
helper.RootEntity = childDb.EntityMaintenance.GetEntityInfo<T>();
var whereSql = helper.GetMppingSql(list, sqlObj.MappingExpressions);
var whereSql = helper.GetMappingSql(list, sqlObj.MappingExpressions);
var navList = selector(childDb.Queryable<object>().AS(GetDbTableName(navEntityInfo, sqlObj)).AddParameters(sqlObj.Parameters).Where(whereSql, true).WhereIF(sqlObj.WhereString.HasValue(), sqlObj.WhereString).Select(sqlObj.SelectString).OrderByIF(sqlObj.OrderByString.HasValue(), sqlObj.OrderByString));
if (navList.HasValue())
{
@@ -684,7 +684,7 @@ namespace ThingsGateway.SqlSugar
}
private void DynamicOneToOne(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo, Expression expression)
private void DynamicOneToOne(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNameProperty, EntityColumnInfo navObjectNameColumnInfo, Expression expression)
{
var navEntity = navObjectNameColumnInfo.PropertyInfo.PropertyType;
var navEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(navEntity);
@@ -701,13 +701,13 @@ namespace ThingsGateway.SqlSugar
}
}
Check.ExceptionEasy(sqlObj.MappingExpressions.IsNullOrEmpty(), $"{expression} errordynamic need MappingField ,Demo: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())", $"{expression}解析出错, 自定义映射需要 MappingField ,例子: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())");
if (list.Count != 0 && navObjectNamePropety.GetValue(list.First()) == null)
if (list.Count != 0 && navObjectNameProperty.GetValue(list.First()) == null)
{
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
helper.Context = this.Context;
helper.NavEntity = navEntityInfo;
helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo<T>();
var whereSql = helper.GetMppingSql(list, sqlObj.MappingExpressions);
var whereSql = helper.GetMappingSql(list, sqlObj.MappingExpressions);
var navList = selector(childDb.Queryable<object>().AS(GetDbTableName(navEntityInfo, sqlObj)).AddParameters(sqlObj.Parameters).Where(whereSql, true).WhereIF(sqlObj.WhereString.HasValue(), sqlObj.WhereString).Select(sqlObj.SelectString).OrderByIF(sqlObj.OrderByString.HasValue(), sqlObj.OrderByString));
if (navList.HasValue())
{
@@ -719,11 +719,11 @@ namespace ThingsGateway.SqlSugar
}
}
private SqlInfo GetWhereSql(SqlSugarProvider db, string properyName = null)
private SqlInfo GetWhereSql(SqlSugarProvider db, string propertyName = null)
{
if (_ListCallFunc == null || _ListCallFunc.Count == 0) return new SqlInfo();
List<string> where = new List<string>();
List<string> oredrBy = new List<string>();
List<string> orderBy = new List<string>();
_ListCallFunc.Reverse();
SqlInfo result = new SqlInfo();
result.Parameters = new List<SugarParameter>();
@@ -752,7 +752,7 @@ namespace ThingsGateway.SqlSugar
queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex;
CheckHasRootShortName(method.Arguments[0], method.Arguments[1]);
var exp = method.Arguments[1];
InitMappingtType(exp);
InitMappingType(exp);
where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
SetTableShortName(result, queryable);
parameterIndex = queryable.QueryBuilder.LambdaExpressions.ParameterIndex;
@@ -765,7 +765,7 @@ namespace ThingsGateway.SqlSugar
{
queryable.QueryBuilder.LambdaExpressions.ParameterIndex = parameterIndex;
var exp = method.Arguments[2];
InitMappingtType(exp);
InitMappingType(exp);
CheckHasRootShortName(method.Arguments[1], method.Arguments[2]);
where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
SetTableShortName(result, queryable);
@@ -775,7 +775,7 @@ namespace ThingsGateway.SqlSugar
else if (method.Method.Name.IsIn("OrderBy", "ThenBy"))
{
var exp = method.Arguments[1];
oredrBy.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
orderBy.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
SetTableShortName(result, queryable);
}
else if (method.Method.Name == "MappingField")
@@ -790,12 +790,12 @@ namespace ThingsGateway.SqlSugar
}
else if (method.Method.Name == "Select")
{
Select(properyName, result, method, queryable);
Select(propertyName, result, method, queryable);
}
else if (method.Method.Name.IsIn("OrderByDescending", "ThenByDescending"))
{
var exp = method.Arguments[1];
oredrBy.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString() + " DESC");
orderBy.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString() + " DESC");
}
else if (method.Method.Name == "Skip")
{
@@ -825,7 +825,7 @@ namespace ThingsGateway.SqlSugar
{
if (method.Arguments.Count > 1)
{
Select(properyName, result, method, queryable);
Select(propertyName, result, method, queryable);
}
isList = true;
}
@@ -846,20 +846,20 @@ namespace ThingsGateway.SqlSugar
Check.ExceptionEasy(isList == false, $"{_ListCallFunc.First()} need is ToList()", $"{_ListCallFunc.First()} 需要ToList");
result.WhereString = String.Join(" AND ", where);
}
if (oredrBy.Count != 0)
if (orderBy.Count != 0)
{
Check.ExceptionEasy(isList == false, $"{_ListCallFunc.First()} need is ToList()", $"{_ListCallFunc.First()} 需要ToList");
result.OrderByString = String.Join(" , ", oredrBy);
result.OrderByString = String.Join(" , ", orderBy);
}
if (result.SelectString.HasValue())
{
Check.ExceptionEasy(isList == false, $"{_ListCallFunc.First()} need is ToList()", $"{_ListCallFunc.First()} 需要ToList");
result.OrderByString = String.Join(" , ", oredrBy);
result.OrderByString = String.Join(" , ", orderBy);
}
return result;
}
private void Select(string properyName, SqlInfo result, MethodCallExpression method, ISugarQueryable<object> queryable)
private void Select(string propertyName, SqlInfo result, MethodCallExpression method, ISugarQueryable<object> queryable)
{
var exp = method.Arguments[1];
var newExp = (exp as LambdaExpression).Body;
@@ -922,9 +922,9 @@ namespace ThingsGateway.SqlSugar
result.SelectString = null;
}
}
if (properyName != null)
if (propertyName != null)
{
var fkColumnsInfo = entityInfo.Columns.FirstOrDefault(x => x.PropertyName == properyName);
var fkColumnsInfo = entityInfo.Columns.FirstOrDefault(x => x.PropertyName == propertyName);
var pkColumnsInfo = entityInfo.Columns.FirstOrDefault(x => x.IsPrimarykey);
if (fkColumnsInfo != null)
{
@@ -1039,7 +1039,7 @@ namespace ThingsGateway.SqlSugar
}
}
private void InitMappingtType(Expression exp)
private void InitMappingType(Expression exp)
{
if (exp is LambdaExpression)
{

View File

@@ -151,10 +151,10 @@ namespace ThingsGateway.SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { getTableNamesFunc });
return this;
}
public QueryMethodInfo SplitTable(DateTime begintTime, DateTime endTime)
public QueryMethodInfo SplitTable(DateTime beginTime, DateTime endTime)
{
var method = QueryableObj.GetType().GetMyMethod("SplitTable", 2, typeof(DateTime), typeof(DateTime));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { begintTime, endTime });
this.QueryableObj = method.Invoke(QueryableObj, new object[] { beginTime, endTime });
return this;
}
public QueryMethodInfo SplitTable()
@@ -218,10 +218,10 @@ namespace ThingsGateway.SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { ignoreNavPropertyNames });
return this;
}
public QueryMethodInfo Includes(string navProperyName)
public QueryMethodInfo Includes(string navPropertyName)
{
var method = QueryableObj.GetType().GetMyMethod("IncludesByNameString", 1, typeof(string));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName });
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navPropertyName });
return this;
}
public QueryMethodInfo IgnoreColumns(params string[] ignoreColumns)
@@ -230,16 +230,16 @@ namespace ThingsGateway.SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { ignoreColumns });
return this;
}
public QueryMethodInfo Includes(string navProperyName, string thenNavProperyName2)
public QueryMethodInfo Includes(string navPropertyName, string thenNavPropertyName2)
{
var method = QueryableObj.GetType().GetMyMethod("IncludesByNameString", 2, typeof(string), typeof(string));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName, thenNavProperyName2 });
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navPropertyName, thenNavPropertyName2 });
return this;
}
public QueryMethodInfo Includes(string navProperyName, string thenNavProperyName2, string thenNavProperyName3)
public QueryMethodInfo Includes(string navPropertyName, string thenNavPropertyName2, string thenNavPropertyName3)
{
var method = QueryableObj.GetType().GetMyMethod("IncludesByNameString", 3, typeof(string), typeof(string), typeof(string));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName, thenNavProperyName2, thenNavProperyName3 });
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navPropertyName, thenNavPropertyName2, thenNavPropertyName3 });
return this;
}
#endregion
@@ -249,66 +249,66 @@ namespace ThingsGateway.SqlSugar
public void IntoTable(Type type, string tableName)
{
var method = QueryableObj.GetType().GetMyMethod("IntoTable", 2, typeof(Type), typeof(string));
var reslt = method.Invoke(QueryableObj, new object[] { type, tableName });
var result = method.Invoke(QueryableObj, new object[] { type, tableName });
}
public object ToPageList(int pageNumber, int pageSize)
{
var method = QueryableObj.GetType().GetMyMethod("ToPageList", 2, typeof(int), typeof(int));
var reslt = method.Invoke(QueryableObj, new object[] { pageNumber, pageSize });
return reslt;
var result = method.Invoke(QueryableObj, new object[] { pageNumber, pageSize });
return result;
}
public object ToPageList(int pageNumber, int pageSize, ref int count)
{
var method = QueryableObj.GetType().GetMyMethod("ToPageList", 3, typeof(int), typeof(int), typeof(int).MakeByRefType());
var parameters = new object[] { pageNumber, pageSize, count };
var reslt = method.Invoke(QueryableObj, parameters);
var result = method.Invoke(QueryableObj, parameters);
count = parameters.Last().ObjToInt();
return reslt;
return result;
}
public object ToList()
{
var method = QueryableObj.GetType().GetMyMethod("ToList", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return reslt;
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return result;
}
public DataTable ToDataTablePage(int pageNumber, int pageSize, ref int count)
{
var method = QueryableObj.GetType().GetMyMethod("ToDataTablePage", 3, typeof(int), typeof(int), typeof(int).MakeByRefType());
var parameters = new object[] { pageNumber, pageSize, count };
var reslt = (DataTable)method.Invoke(QueryableObj, parameters);
var result = (DataTable)method.Invoke(QueryableObj, parameters);
count = parameters.Last().ObjToInt();
return reslt;
return result;
}
public DataTable ToDataTablePage(int pageNumber, int pageSize)
{
var method = QueryableObj.GetType().GetMyMethod("ToDataTablePage", 2, typeof(int), typeof(int));
var parameters = new object[] { pageNumber, pageSize };
var reslt = (DataTable)method.Invoke(QueryableObj, parameters);
return reslt;
var result = (DataTable)method.Invoke(QueryableObj, parameters);
return result;
}
public DataTable ToDataTable()
{
var method = QueryableObj.GetType().GetMyMethod("ToDataTable", 0);
var reslt = (DataTable)method.Invoke(QueryableObj, Array.Empty<object>());
return reslt;
var result = (DataTable)method.Invoke(QueryableObj, Array.Empty<object>());
return result;
}
public string ToSqlString()
{
var method = QueryableObj.GetType().GetMyMethod("ToSqlString", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return (string)reslt;
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return (string)result;
}
public KeyValuePair<string, List<SugarParameter>> ToSql()
{
var method = QueryableObj.GetType().GetMyMethod("ToSql", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return (KeyValuePair<string, List<SugarParameter>>)reslt;
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return (KeyValuePair<string, List<SugarParameter>>)result;
}
public object InSingle(object pkValue)
{
var method = QueryableObj.GetType().GetMyMethod("InSingle", 1);
var reslt = method.Invoke(QueryableObj, new object[] { pkValue });
return reslt;
var result = method.Invoke(QueryableObj, new object[] { pkValue });
return result;
}
public bool CreateView(string viewNameFomat)
{
@@ -321,8 +321,8 @@ namespace ThingsGateway.SqlSugar
if (!this.Context.DbMaintenance.GetViewInfoList().Any(it => it.Name.EqualCase(viewName)))
{
var method = QueryableObj.GetType().GetMyMethod("ToSqlString", 0);
var reslt = (string)method.Invoke(QueryableObj, Array.Empty<object>());
var sql = $"CREATE VIEW {viewName} AS {Environment.NewLine} {reslt}";
var result = (string)method.Invoke(QueryableObj, Array.Empty<object>());
var sql = $"CREATE VIEW {viewName} AS {Environment.NewLine} {result}";
this.Context.Ado.ExecuteCommand(sql);
return true;
}
@@ -334,26 +334,26 @@ namespace ThingsGateway.SqlSugar
public object First()
{
var method = QueryableObj.GetType().GetMyMethod("First", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return reslt;
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return result;
}
public bool Any()
{
var method = QueryableObj.GetType().GetMyMethod("Any", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return Convert.ToBoolean(reslt);
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return Convert.ToBoolean(result);
}
public int Count()
{
var method = QueryableObj.GetType().GetMyMethod("Count", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return Convert.ToInt32(reslt);
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return Convert.ToInt32(result);
}
public object ToTree(string childPropertyName, string parentIdPropertyName, object rootValue, string primaryKeyPropertyName)
{
var method = QueryableObj.GetType().GetMyMethod("ToTree", 4, typeof(string), typeof(string), typeof(object), typeof(string));
var reslt = method.Invoke(QueryableObj, new object[] { childPropertyName, parentIdPropertyName, rootValue, primaryKeyPropertyName });
return reslt;
var result = method.Invoke(QueryableObj, new object[] { childPropertyName, parentIdPropertyName, rootValue, primaryKeyPropertyName });
return result;
}
#endregion
@@ -408,14 +408,14 @@ namespace ThingsGateway.SqlSugar
public async Task<bool> AnyAsync()
{
var method = QueryableObj.GetType().GetMyMethod("AnyAsync", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return await ((Task<bool>)reslt).ConfigureAwait(false);
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return await ((Task<bool>)result).ConfigureAwait(false);
}
public async Task<int> CountAsync()
{
var method = QueryableObj.GetType().GetMyMethod("CountAsync", 0);
var reslt = method.Invoke(QueryableObj, Array.Empty<object>());
return await ((Task<int>)reslt).ConfigureAwait(false);
var result = method.Invoke(QueryableObj, Array.Empty<object>());
return await ((Task<int>)result).ConfigureAwait(false);
}
public async Task<object> InSingleAsync(object pkValue)
{

View File

@@ -658,7 +658,7 @@ namespace ThingsGateway.SqlSugar
RightEntityColumn=rightEntity.Columns.First(it=>it.PropertyName==ExpressionTool.GetMemberName(mappingField2))
}
};
var conditionals = fieldsHelper.GetMppingSql(list.Cast<object>().ToList(), mappings);
var conditionals = fieldsHelper.GetMappingSql(list.Cast<object>().ToList(), mappings);
if (queryableContext.TempChildLists == null)
queryableContext.TempChildLists = new Dictionary<string, object>();
if (list != null && queryableContext.TempChildLists.TryGetValue(key, out object? value))

View File

@@ -123,10 +123,10 @@ namespace ThingsGateway.SqlSugar
{
return (await Clone().Take(1).Select("1").ToListAsync().ConfigureAwait(false)).Count > 0;
}
public virtual Task<bool> AnyAsync(CancellationToken token)
public virtual Task<bool> AnyAsync(CancellationToken token)
{
this.Context.Ado.CancellationToken = token;
return this.AnyAsync();
return this.AnyAsync();
}
public Task<int> CountAsync(CancellationToken token)
{
@@ -537,7 +537,7 @@ ParameterT parameter)
RightEntityColumn=rightEntity.Columns.First(it=>it.PropertyName==ExpressionTool.GetMemberName(mappingField2))
}
};
var conditionals = fieldsHelper.GetMppingSql(list.Cast<object>().ToList(), mappings);
var conditionals = fieldsHelper.GetMappingSql(list.Cast<object>().ToList(), mappings);
if (queryableContext.TempChildLists == null)
queryableContext.TempChildLists = new Dictionary<string, object>();
if (list != null && queryableContext.TempChildLists.TryGetValue(key, out object? value))

View File

@@ -297,7 +297,7 @@ namespace ThingsGateway.SqlSugar
return result;
}
private List<object> GetPrentIds(List<T> list, object id, EntityColumnInfo pkName, EntityColumnInfo parentName)
private List<object> GetParentIds(List<T> list, object id, EntityColumnInfo pkName, EntityColumnInfo parentName)
{
var currentId = id;
List<object> result = new List<object>();
@@ -320,7 +320,7 @@ namespace ThingsGateway.SqlSugar
var parentColumn = entity.Columns.FirstOrDefault(z => z.PropertyName == parentIdName);
foreach (var id in childIds)
{
newIds.AddRange(GetPrentIds(list, id, pkColumn, parentColumn));
newIds.AddRange(GetParentIds(list, id, pkColumn, parentColumn));
}
list = list.Where(z => newIds.Any(it => it.ObjToString() == pkColumn.PropertyInfo.GetValue(z).ObjToString())).ToList();
return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue);
@@ -335,7 +335,7 @@ namespace ThingsGateway.SqlSugar
var parentColumn = entity.Columns.FirstOrDefault(z => z.PropertyName == parentIdName);
foreach (var id in childIds)
{
newIds.AddRange(GetPrentIds(list, id, pkColumn, parentColumn));
newIds.AddRange(GetParentIds(list, id, pkColumn, parentColumn));
}
list = list.Where(z => newIds.Any(it => it.ObjToString() == pkColumn.PropertyInfo.GetValue(z).ObjToString())).ToList();
return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue);
@@ -491,9 +491,9 @@ namespace ThingsGateway.SqlSugar
QueryBuilder.CheckExpression(expression, "Max");
var isSingle = QueryBuilder.IsSingle();
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
var reslut = Max<TResult>(lamResult.GetResultString());
var result = Max<TResult>(lamResult.GetResultString());
QueryBuilder.SelectValue = null;
return reslut;
return result;
}
protected async Task<TResult> _MaxAsync<TResult>(Expression expression)
{
@@ -504,9 +504,9 @@ namespace ThingsGateway.SqlSugar
QueryBuilder.CheckExpression(expression, "Max");
var isSingle = QueryBuilder.IsSingle();
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
var reslut = await MaxAsync<TResult>(lamResult.GetResultString()).ConfigureAwait(false);
var result = await MaxAsync<TResult>(lamResult.GetResultString()).ConfigureAwait(false);
QueryBuilder.SelectValue = null;
return reslut;
return result;
}
protected TResult _Sum<TResult>(Expression expression)
{
@@ -517,9 +517,9 @@ namespace ThingsGateway.SqlSugar
QueryBuilder.CheckExpression(expression, "Sum");
var isSingle = QueryBuilder.IsSingle();
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
var reslut = Sum<TResult>(lamResult.GetResultString());
var result = Sum<TResult>(lamResult.GetResultString());
QueryBuilder.SelectValue = null;
return reslut;
return result;
}
protected async Task<TResult> _SumAsync<TResult>(Expression expression)
{
@@ -530,9 +530,9 @@ namespace ThingsGateway.SqlSugar
QueryBuilder.CheckExpression(expression, "Sum");
var isSingle = QueryBuilder.IsSingle();
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
var reslut = await SumAsync<TResult>(lamResult.GetResultString()).ConfigureAwait(false);
var result = await SumAsync<TResult>(lamResult.GetResultString()).ConfigureAwait(false);
QueryBuilder.SelectValue = null;
return reslut;
return result;
}
#endregion
@@ -2430,7 +2430,7 @@ namespace ThingsGateway.SqlSugar
var addItem = list[appindex];
if (addItem is SubQueryToListDefaultT)
{
addItem = (addItem as SubQueryToListDefaultT).id;
addItem = (addItem as SubQueryToListDefaultT).Id;
}
setValue.Add(addItem);
}
@@ -2515,7 +2515,7 @@ namespace ThingsGateway.SqlSugar
var addItem = list[appindex];
if (addItem is SubQueryToListDefaultT)
{
addItem = ((SubQueryToListDefaultT)addItem).id;
addItem = ((SubQueryToListDefaultT)addItem).Id;
}
if (addItem != null && addItem is string && itemProperty?.PropertyType?.GenericTypeArguments?.FirstOrDefault() == UtilConstants.GuidType)
{

View File

@@ -1398,12 +1398,12 @@ namespace ThingsGateway.SqlSugar
public virtual ISugarQueryable<T> GroupBy(string groupFields)
{
groupFields = groupFields.ToCheckField();
var croupByValue = QueryBuilder.GroupByValue;
var groupByValue = QueryBuilder.GroupByValue;
if (QueryBuilder.GroupByValue.IsNullOrEmpty())
{
QueryBuilder.GroupByValue = QueryBuilder.GroupByTemplate;
}
QueryBuilder.GroupByValue += string.IsNullOrEmpty(croupByValue) ? groupFields : ("," + groupFields);
QueryBuilder.GroupByValue += string.IsNullOrEmpty(groupByValue) ? groupFields : ("," + groupFields);
return this;
}

View File

@@ -1126,16 +1126,16 @@ namespace ThingsGateway.SqlSugar
if (IsSingle() == false && this.JoinExpression != null)
{
var jsoinParameters = (this.JoinExpression as LambdaExpression).Parameters;
var currentParametres = (expression as LambdaExpression).Parameters;
var currentParameters = (expression as LambdaExpression).Parameters;
if ((expression as LambdaExpression).Body.ToString() == "True")
{
return;
}
if (currentParametres?.Count > 0)
if (currentParameters?.Count > 0)
{
foreach (var item in currentParametres)
foreach (var item in currentParameters)
{
var index = currentParametres.IndexOf(item);
var index = currentParameters.IndexOf(item);
var name = item.Name;
var joinName = jsoinParameters[index].Name;
Check.Exception(!name.Equals(joinName, StringComparison.CurrentCultureIgnoreCase), ErrorMessage.ExpressionCheck, joinName, methodName, name);
@@ -1148,22 +1148,22 @@ namespace ThingsGateway.SqlSugar
if (IsSingle() == false && this.JoinExpression != null)
{
var jsoinParameters = (this.JoinExpression as LambdaExpression).Parameters;
var currentParametres = (expression as LambdaExpression).Parameters;
var currentParameters = (expression as LambdaExpression).Parameters;
if ((expression as LambdaExpression).Body.ToString() == "True")
{
return;
}
if (currentParametres?.Count > 0)
if (currentParameters?.Count > 0)
{
if (jsoinParameters.Count + 1 != currentParametres.Count)
if (jsoinParameters.Count + 1 != currentParameters.Count)
{
var str1 = "(" + string.Join(",", currentParametres.Select(it => it.Name)) + ")=>";
var str2 = "(" + string.Join(",", jsoinParameters.Select(it => it.Name)) + "," + currentParametres.Last().Type.Name + " )=>";
throw new Exception(ErrorMessage.GetThrowMessage($"Join {currentParametres.Last().Type.Name} error , Please change {str1} to {str2}.", $"Join {currentParametres.Last().Type.Name} 错误, 请把 {str1} 改成 {str2} "));
var str1 = "(" + string.Join(",", currentParameters.Select(it => it.Name)) + ")=>";
var str2 = "(" + string.Join(",", jsoinParameters.Select(it => it.Name)) + "," + currentParameters.Last().Type.Name + " )=>";
throw new Exception(ErrorMessage.GetThrowMessage($"Join {currentParameters.Last().Type.Name} error , Please change {str1} to {str2}.", $"Join {currentParameters.Last().Type.Name} 错误, 请把 {str1} 改成 {str2} "));
}
foreach (var item in currentParametres.Take(jsoinParameters.Count))
foreach (var item in currentParameters.Take(jsoinParameters.Count))
{
var index = currentParametres.IndexOf(item);
var index = currentParameters.IndexOf(item);
var name = item.Name;
var joinName = jsoinParameters[index].Name;
Check.Exception(!name.Equals(joinName, StringComparison.CurrentCultureIgnoreCase), ErrorMessage.ExpressionCheck, joinName, methodName, name);

View File

@@ -960,18 +960,18 @@ namespace ThingsGateway.SqlSugar
}
public UpdateExpressionMethodInfo UpdateableByObject(Type entityType)
{
UpdateExpressionMethodInfo reslut = new UpdateExpressionMethodInfo();
UpdateExpressionMethodInfo result = new UpdateExpressionMethodInfo();
var methods = this.Context.GetType().GetMethods()
.Where(it => it.Name == "Updateable")
.Where(it => it.GetGenericArguments().Length != 0)
.Where(it => it.GetParameters().Length == 0)
.Where(it => it.Name == "Updateable").ToList();
var method = methods.Single().MakeGenericMethod(entityType);
reslut.Context = this.Context;
reslut.MethodInfo = method;
reslut.Type = entityType;
reslut.objectValue = method.Invoke(Context, Array.Empty<object>());
return reslut;
result.Context = this.Context;
result.MethodInfo = method;
result.Type = entityType;
result.objectValue = method.Invoke(Context, Array.Empty<object>());
return result;
}
public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
{

View File

@@ -11,11 +11,11 @@ namespace ThingsGateway.SqlSugar
{
var type = MethodInfos.GetType().GetGenericArguments()[0];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.MethodInfos.GetType().GetMyMethod("Include", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions });
this.MethodInfos = obj;
return this;
@@ -24,11 +24,11 @@ namespace ThingsGateway.SqlSugar
{
var type = MethodInfos.GetType().GetGenericArguments()[1];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Type properyItemType;
Type propertyItemType;
bool isList;
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out propertyItemType, out isList);
var method = this.MethodInfos.GetType().GetMyMethod("ThenInclude", 2, isList)
.MakeGenericMethod(properyItemType);
.MakeGenericMethod(propertyItemType);
var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions });
this.MethodInfos = obj;
return this;

View File

@@ -50,15 +50,15 @@ namespace ThingsGateway.SqlSugar
public EntityInfo Entity { get; set; }
public object GetValue(string propertyName)
{
var propety = EntityColumnInfos.FirstOrDefault(it => it.PropertyName == propertyName);
Check.ExceptionEasy(propety == null, $"Aop.DataExecuted error . {Entity.EntityName} no property {propertyName}.", $"Aop.DataExecuted 出错 {Entity.EntityName}不存在属性{propertyName}");
return propety.PropertyInfo.GetValue(EntityValue);
var property = EntityColumnInfos.FirstOrDefault(it => it.PropertyName == propertyName);
Check.ExceptionEasy(property == null, $"Aop.DataExecuted error . {Entity.EntityName} no property {propertyName}.", $"Aop.DataExecuted 出错 {Entity.EntityName}不存在属性{propertyName}");
return property.PropertyInfo.GetValue(EntityValue);
}
public void SetValue(string propertyName, object value)
{
var propety = EntityColumnInfos.FirstOrDefault(it => it.PropertyName == propertyName);
Check.ExceptionEasy(propety == null, $"Aop.DataExecuted error . {Entity.EntityName} no property {propertyName}.", $"Aop.DataExecuted 出错 {Entity.EntityName}不存在属性{propertyName}");
propety.PropertyInfo.SetValue(EntityValue, value);
var property = EntityColumnInfos.FirstOrDefault(it => it.PropertyName == propertyName);
Check.ExceptionEasy(property == null, $"Aop.DataExecuted error . {Entity.EntityName} no property {propertyName}.", $"Aop.DataExecuted 出错 {Entity.EntityName}不存在属性{propertyName}");
property.PropertyInfo.SetValue(EntityValue, value);
}
}
}

View File

@@ -70,21 +70,21 @@ namespace ThingsGateway.SqlSugar
public string[] GetResultArray()
{
if (this._Result == null) return null;
var reslut = new List<string>();
var result = new List<string>();
if (IsUpper)
reslut = this.Result.ToString().ToUpper().TrimEnd(',').Split(',').ToList();
result = this.Result.ToString().ToUpper().TrimEnd(',').Split(',').ToList();
else
reslut = this.Result.ToString().TrimEnd(',').Split(',').ToList();
result = this.Result.ToString().TrimEnd(',').Split(',').ToList();
if (this.Result.ToString().Contains(UtilConstants.ReplaceCommaKey))
{
for (int i = 0; i < reslut.Count; i++)
for (int i = 0; i < result.Count; i++)
{
reslut[i] = reslut[i].Replace(UtilConstants.ReplaceCommaKey, ",");
result[i] = result[i].Replace(UtilConstants.ReplaceCommaKey, ",");
}
}
return reslut.ToArray();
return result.ToArray();
}
public string GetResultString()

View File

@@ -421,13 +421,13 @@ namespace ThingsGateway.SqlSugar
var listPkColumn = listItemEntity.Columns.Where(it => it.IsPrimarykey).FirstOrDefault();
navObjectName = memberExpression.Member.Name;
var navObjectName2 = navObjectName;
var navObjectNamePropety = listItemType.GetProperty(navObjectName);
var navObjectNameProperty = listItemType.GetProperty(navObjectName);
var navObjectNameColumnInfo = listItemEntity.Columns.First(it => it.PropertyName == navObjectName2);
Check.ExceptionEasy(navObjectNameColumnInfo.Navigat == null, $"{navObjectName} not [Navigat(..)] ", $"{navObjectName} 没有导航特性 [Navigat(..)] ");
Check.ExceptionEasy(navObjectNameColumnInfo.Navigat.NavigatType != NavigateType.OneToOne, $"IncludeLeftJoin can only be one-on-one ", $"IncludeLeftJoin 只能是一对一 ");
navColumn = listItemEntity.Columns.FirstOrDefault(it => it.PropertyName == navObjectNameColumnInfo.Navigat.Name);
Check.ExceptionEasy(navColumn == null, "OneToOne navigation configuration error", $"OneToOne导航配置错误 实体{listItemEntity.EntityName} 不存在{navObjectNameColumnInfo.Navigat.Name}");
var navType = navObjectNamePropety.PropertyType;
var navType = navObjectNameProperty.PropertyType;
navEntityInfo = context.EntityMaintenance.GetEntityInfo(navType);
context.InitMappingInfo(navEntityInfo.Type);
navPkColumn = navEntityInfo.Columns.Where(it => it.IsPrimarykey).FirstOrDefault();

View File

@@ -534,27 +534,27 @@ namespace ThingsGateway.SqlSugar
public virtual string CaseWhen(List<KeyValuePair<string, string>> sqls)
{
StringBuilder reslut = new StringBuilder();
StringBuilder result = new StringBuilder();
foreach (var item in sqls)
{
if (item.Key == "IF")
{
reslut.AppendFormat(" ( CASE WHEN {0} ", item.Value);
result.AppendFormat(" ( CASE WHEN {0} ", item.Value);
}
else if (item.Key == "End")
{
reslut.AppendFormat("ELSE {0} END )", item.Value);
result.AppendFormat("ELSE {0} END )", item.Value);
}
else if (item.Key == "Return")
{
reslut.AppendFormat(" THEN {0} ", item.Value);
result.AppendFormat(" THEN {0} ", item.Value);
}
else
{
reslut.AppendFormat(" WHEN {0} ", item.Value);
result.AppendFormat(" WHEN {0} ", item.Value);
}
}
return reslut.ToString();
return result.ToString();
}
public virtual string CharIndex(MethodCallExpressionModel model)
{

View File

@@ -1,5 +1,4 @@
using System.Linq.Expressions;
using System.Reflection;
namespace ThingsGateway.SqlSugar
{
public class MemberInitExpressionResolve : BaseResolve

View File

@@ -518,10 +518,10 @@ namespace ThingsGateway.SqlSugar
else if (!(item is ParameterExpression) && name.IsIn("Contains", "StartsWith", "EndsWith") && item == args.Last() && ExpressionTool.IsSqlParameterDbType(this.Context, args.First()))
{
var myvalue = ExpressionTool.DynamicInvoke(args.Last());
var parametre = ExpressionTool.GetParameterBySqlParameterDbType(this.Context.ParameterIndex, myvalue, this.Context, args.First());
this.Context.Parameters.Add(parametre);
methodCallExpressionArgs.MemberName = parametre.ParameterName;
methodCallExpressionArgs.MemberValue = parametre.Value;
var parameter1 = ExpressionTool.GetParameterBySqlParameterDbType(this.Context.ParameterIndex, myvalue, this.Context, args.First());
this.Context.Parameters.Add(parameter1);
methodCallExpressionArgs.MemberName = parameter1.ParameterName;
methodCallExpressionArgs.MemberValue = parameter1.Value;
methodCallExpressionArgs.IsMember = true;
isRemoveParamter = true;
this.Context.ParameterIndex++;
@@ -598,8 +598,8 @@ namespace ThingsGateway.SqlSugar
var member = exp as MemberExpression;
var it = member.Expression;
var type = it.Type;
var properyName = member.Member.Name;
var eqName = string.Format("{0}.{1}", this.Context.GetTranslationColumnName(it.ToString()), this.Context.GetDbColumnName(type.Name, properyName));
var propertyName = member.Member.Name;
var eqName = string.Format("{0}.{1}", this.Context.GetTranslationColumnName(it.ToString()), this.Context.GetDbColumnName(type.Name, propertyName));
if (this.Context.IsSingle)
{
this.Context.SingleTableNameSubqueryShortName = it.ToString();

View File

@@ -73,8 +73,8 @@ namespace ThingsGateway.SqlSugar
lastShortName = shortName;
formInfo = item;
}
var selectProperyInfo = ExpressionTool.GetMemberName(memberInfo.Expression);
var selectColumnInfo = memberInfo.ParentEntityInfo.Columns.First(it => it.PropertyName == selectProperyInfo);
var selectPropertyInfo = ExpressionTool.GetMemberName(memberInfo.Expression);
var selectColumnInfo = memberInfo.ParentEntityInfo.Columns.First(it => it.PropertyName == selectPropertyInfo);
if (rootWhereSql?.HasValue() == true)
{
queryable.Where(rootWhereSql);

View File

@@ -40,7 +40,7 @@ namespace ThingsGateway.SqlSugar
{
var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
@@ -55,7 +55,7 @@ namespace ThingsGateway.SqlSugar
this.Context.RefreshMapping();
}
var result = "AVG(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
var selfParameterName = Context.GetTranslationColumnName(parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;

View File

@@ -41,7 +41,7 @@ namespace ThingsGateway.SqlSugar
var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0];
InitType(exp);
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
@@ -56,7 +56,7 @@ namespace ThingsGateway.SqlSugar
this.Context.RefreshMapping();
}
var result = "COUNT(DISTINCT " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
var selfParameterName = Context.GetTranslationColumnName(parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;

View File

@@ -60,7 +60,7 @@ namespace ThingsGateway.SqlSugar
return "*,@sugarIndex as sugarIndex";
}
var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;

View File

@@ -40,7 +40,7 @@ namespace ThingsGateway.SqlSugar
{
var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
@@ -55,7 +55,7 @@ namespace ThingsGateway.SqlSugar
this.Context.RefreshMapping();
}
var result = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
var selfParameterName = Context.GetTranslationColumnName(parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;

View File

@@ -40,7 +40,7 @@ namespace ThingsGateway.SqlSugar
{
var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
@@ -55,7 +55,7 @@ namespace ThingsGateway.SqlSugar
this.Context.RefreshMapping();
}
var result = "MIN(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
var selfParameterName = Context.GetTranslationColumnName(parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;

View File

@@ -40,7 +40,7 @@ namespace ThingsGateway.SqlSugar
{
var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
@@ -55,7 +55,7 @@ namespace ThingsGateway.SqlSugar
this.Context.RefreshMapping();
}
var result = "SUM(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;
var selfParameterName = Context.GetTranslationColumnName(parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;

View File

@@ -60,7 +60,7 @@ namespace ThingsGateway.SqlSugar
return "*,@sugarIndex as sugarIndex";
}
var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters;
var parameters = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression)
{
argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;

View File

@@ -16,8 +16,8 @@ namespace ThingsGateway.SqlSugar
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3);
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3, string thenNavMemberName4);
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3, string thenNavMemberName4, string thenNavMemberName5);
ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignoreProperyNameList);
ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression, params string[] ignoreProperyNameList);
ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignorePropertyNameList);
ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression, params string[] ignorePropertyNameList);
ISugarQueryable<T> Includes<TReturn1>(Expression<Func<T, List<TReturn1>>> include1);
ISugarQueryable<T> Includes<TReturn1>(Expression<Func<T, TReturn1>> include1);
ISugarQueryable<T> Includes<TReturn1, TReturn2>(Expression<Func<T, List<TReturn1>>> include1, Expression<Func<TReturn1, List<TReturn2>>> include2);

View File

@@ -170,7 +170,7 @@ namespace ThingsGateway.SqlSugar
}
else if (type == DBNull.Value.GetType())
{
DbNullParametrerArray(parameter, sqlParameter);
DbNullParameterrArray(parameter, sqlParameter);
}
else
@@ -179,7 +179,7 @@ namespace ThingsGateway.SqlSugar
}
}
private static void DbNullParametrerArray(SugarParameter parameter, NpgsqlParameter sqlParameter)
private static void DbNullParameterrArray(SugarParameter parameter, NpgsqlParameter sqlParameter)
{
if (parameter.DbType.IsIn(System.Data.DbType.Int32))
{

View File

@@ -32,12 +32,12 @@ namespace ThingsGateway.SqlSugar
}
}
columns = columns.OrderBy(it => it.IsPrimarykey ? 0 : 1).ToList();
foreach (var propety in entityInfo.Type.GetProperties())
foreach (var property in entityInfo.Type.GetProperties())
{
var timeAttr = propety.GetCustomAttribute<TimeDbSplitFieldAttribute>();
var timeAttr = property.GetCustomAttribute<TimeDbSplitFieldAttribute>();
if (timeAttr != null)
{
var colName = columns.FirstOrDefault(it => it.PropertyName == propety.Name)?.DbColumnName;
var colName = columns.FirstOrDefault(it => it.PropertyName == property.Name)?.DbColumnName;
tableName += $"_TIMESTAMP({colName}) PARTITION BY {timeAttr.DateType} ";
}
}

View File

@@ -4,7 +4,7 @@ namespace ThingsGateway.SqlSugar
public class SqlSugarException : Exception
{
public string Sql { get; set; }
public object Parametres { get; set; }
public object Parameters { get; set; }
public new Exception InnerException;
public new string StackTrace;
public new MethodBase TargetSite;
@@ -23,14 +23,14 @@ namespace ThingsGateway.SqlSugar
: base(message)
{
this.Sql = sql;
this.Parametres = pars;
this.Parameters = pars;
}
public SqlSugarException(SqlSugarProvider context, Exception ex, string sql, object pars)
: base(ex.Message)
{
this.Sql = sql;
this.Parametres = pars;
this.Parameters = pars;
this.InnerException = ex.InnerException;
this.StackTrace = ex.StackTrace;
this.TargetSite = ex.TargetSite;
@@ -40,7 +40,7 @@ namespace ThingsGateway.SqlSugar
public SqlSugarException(SqlSugarProvider context, string message, object pars)
: base(message)
{
this.Parametres = pars;
this.Parameters = pars;
}
public SqlSugarException() : base()

View File

@@ -354,21 +354,21 @@ namespace ThingsGateway.SqlSugar
}
}
internal static Expression GetIncludeExpression(string navMemberName, EntityInfo entityInfo, out Type properyItemType, out bool isList)
internal static Expression GetIncludeExpression(string navMemberName, EntityInfo entityInfo, out Type propertyItemType, out bool isList)
{
var navInfo = entityInfo.Columns.Where(it => it.Navigat != null && it.PropertyName.EqualCase(navMemberName)).FirstOrDefault();
var properyType = navInfo.PropertyInfo.PropertyType;
properyItemType = properyType;
if (properyType.FullName.IsCollectionsList())
var propertyType = navInfo.PropertyInfo.PropertyType;
propertyItemType = propertyType;
if (propertyType.FullName.IsCollectionsList())
{
properyItemType = properyType.GetGenericArguments()[0];
propertyItemType = propertyType.GetGenericArguments()[0];
isList = true;
}
else
{
isList = false;
}
return ExpressionBuilderHelper.CreateExpressionSelectField(entityInfo.Type, navInfo.PropertyName, properyType);
return ExpressionBuilderHelper.CreateExpressionSelectField(entityInfo.Type, navInfo.PropertyName, propertyType);
}
public static string RemoveEqualOne(string value)
{
@@ -1687,10 +1687,10 @@ namespace ThingsGateway.SqlSugar
string FirstDay = datetime.AddDays(daydiff).ToString("yyyy-MM-dd");
return Convert.ToDateTime(FirstDay);
}
public static string GetSqlString(DbType dbType, string sql, SugarParameter[] parametres, bool DisableNvarchar = false)
public static string GetSqlString(DbType dbType, string sql, SugarParameter[] parameters, bool DisableNvarchar = false)
{
if (parametres == null)
parametres = Array.Empty<SugarParameter>();
if (parameters == null)
parameters = Array.Empty<SugarParameter>();
return GetSqlString(new ConnectionConfig()
{
DbType = dbType,
@@ -1698,7 +1698,7 @@ namespace ThingsGateway.SqlSugar
{
DisableNvarchar = DisableNvarchar
}
}, new KeyValuePair<string, List<SugarParameter>>(sql, parametres.ToList()));
}, new KeyValuePair<string, List<SugarParameter>>(sql, parameters.ToList()));
}
public static string GetSqlString(ConnectionConfig connectionConfig, KeyValuePair<string, List<SugarParameter>> sqlObj)
{