From 65ddacd31388ff0f0209a7ea913c20c72e9c156e Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 7 Jul 2023 11:27:19 +0800 Subject: [PATCH] Update nav query --- .../QueryableProvider/NavigatManager.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs index d3de1759a..1090de805 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs @@ -332,12 +332,16 @@ namespace SqlSugar } var ids = list.Select(it => it.GetType().GetProperty(navObjectNameColumnInfo.Navigat.Name).GetValue(it)).Select(it => it == null ? "null" : it).Distinct().ToList(); List conditionalModels = new List(); + if (IsEnumNumber(navColumn)) + { + ids = ids.Select(it => Convert.ToInt64(it)).Cast().ToList(); + } conditionalModels.Add((new ConditionalModel() { ConditionalType = ConditionalType.In, FieldName = navPkColumn.DbColumnName, FieldValue = String.Join(",", ids), - CSharpTypeName = navPkColumn.PropertyInfo.PropertyType.Name + CSharpTypeName = navPkColumn?.UnderType?.Name })); if (list.Any()&&navObjectNamePropety.GetValue(list.First()) == null) { @@ -393,12 +397,16 @@ namespace SqlSugar } var ids = list.Select(it => it.GetType().GetProperty(listItemPkColumn.PropertyName).GetValue(it)).Select(it => it == null ? "null" : it).Distinct().ToList(); List conditionalModels = new List(); + if (IsEnumNumber(navColumn)) + { + ids = ids.Select(it => Convert.ToInt64(it)).Cast().ToList(); + } conditionalModels.Add((new ConditionalModel() { ConditionalType = ConditionalType.In, FieldName = navColumn.DbColumnName, FieldValue = String.Join(",", ids), - CSharpTypeName = listItemPkColumn.PropertyInfo.PropertyType.Name + CSharpTypeName = listItemPkColumn?.UnderType?.Name })); var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name); @@ -818,5 +826,12 @@ namespace SqlSugar } + private bool IsEnumNumber(EntityColumnInfo navPkColumn) + { + return + navPkColumn?.UnderType?.IsEnum()==true && + navPkColumn?.SqlParameterDbType == null && + this.Context?.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString != true; + } } }