diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 9f6778ce3..353f37e82 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -735,6 +735,7 @@ namespace SqlSugar } public virtual ISugarQueryable OrderBy(string orderFileds) { + orderFileds = orderFileds.ToCheckField(); var orderByValue = QueryBuilder.OrderByValue; if (QueryBuilder.OrderByValue.IsNullOrEmpty()) { @@ -771,6 +772,7 @@ namespace SqlSugar public virtual ISugarQueryable GroupBy(string groupFileds) { + groupFileds = groupFileds.ToCheckField(); var croupByValue = QueryBuilder.GroupByValue; if (QueryBuilder.GroupByValue.IsNullOrEmpty()) { diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs index a7c3db05e..5a3fcf213 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs @@ -160,7 +160,7 @@ namespace SqlSugar } string oldName = item.FieldName; item.FieldName = GetTranslationColumnName(item.FieldName); - Check.Exception(item.FieldName.Contains("--"), "Field name is error format"); + item.FieldName = item.FieldName.ToCheckField(); switch (item.ConditionalType) { case ConditionalType.Equal: diff --git a/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs b/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs index 7ac9fe2e6..83ae52529 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs @@ -47,6 +47,26 @@ namespace SqlSugar return value; } + /// + /// Check field format + /// + /// + /// + public static string ToCheckField(this string value) + { + if (value != null) + { + if (value.IsContainsIn(";", "--")) + { + throw new Exception($"{value} format error "); + } + else if (value.IsContainsIn("'")&&(value.Length- value.Replace("'","").Length)%2!=0) + { + throw new Exception($"{value} format error "); + } + } + return value; + } internal static string ToLower(this string value ,bool isAutoToLower) { if (value == null) return null;