From 27acf4c5236bb11a2ef3c9fdd7fcbff0336b13e5 Mon Sep 17 00:00:00 2001 From: xusc Date: Wed, 6 Nov 2024 10:32:28 +0800 Subject: [PATCH] .. --- .../ICS.Common/Extension/LinqExpressionExt.cs | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/aspnet-core/ICS.Common/Extension/LinqExpressionExt.cs b/src/aspnet-core/ICS.Common/Extension/LinqExpressionExt.cs index b3df7548..9e833d67 100644 --- a/src/aspnet-core/ICS.Common/Extension/LinqExpressionExt.cs +++ b/src/aspnet-core/ICS.Common/Extension/LinqExpressionExt.cs @@ -20,59 +20,57 @@ namespace ICS.Common.Extension Expression> condition = null; try { - if (filterConditionList != null && filterConditionList.Count > 0) + foreach (FilterModel filterCondition in filterConditionList) { - foreach (FilterModel filterCondition in filterConditionList) + if (string.IsNullOrEmpty(filterCondition.ColumnAction)) { - if (string.IsNullOrEmpty(filterCondition.ColumnAction)) + continue; + } + if (filterCondition.ColumnDataType != ConfigColumnDataType.type_string.ToString()) + { + if (string.IsNullOrEmpty(filterCondition.ColumnValue)) { continue; } - if (filterCondition.ColumnDataType != ConfigColumnDataType.type_string.ToString()) + } + else + { + if (ConfigColumnAction.Contains.ToString().Equals(filterCondition.ColumnAction) + || ConfigColumnAction.NotContains.ToString().Equals(filterCondition.ColumnAction)) { if (string.IsNullOrEmpty(filterCondition.ColumnValue)) { continue; } } - else + } + Expression> tempCondition = CreateLambda(filterCondition); + if (condition == null) + { + condition = tempCondition; + } + else + { + if (tempCondition == null) { - if (ConfigColumnAction.Contains.ToString().Equals(filterCondition.ColumnAction) - || ConfigColumnAction.NotContains.ToString().Equals(filterCondition.ColumnAction)) - { - if (string.IsNullOrEmpty(filterCondition.ColumnValue)) - { - continue; - } - } + continue; + } + if (ConfigColumnLogic.AND.ToString().Equals(filterCondition.ColumnLogic)) + { + + condition = condition.And(tempCondition); } - Expression> tempCondition = CreateLambda(filterCondition); - if (condition == null) + else if (ConfigColumnLogic.OR.ToString().Equals(filterCondition.ColumnLogic)) { - condition = tempCondition; + condition = condition.Or(tempCondition); } else { - if (tempCondition == null) - { - continue; - } - if (ConfigColumnLogic.AND.ToString().Equals(filterCondition.ColumnLogic)) - { - condition = condition.And(tempCondition); - } - else if (ConfigColumnLogic.OR.ToString().Equals(filterCondition.ColumnLogic)) - { - condition = condition.Or(tempCondition); - } - else - { - - } } } } + } catch (Exception ex) { @@ -167,7 +165,7 @@ namespace ICS.Common.Extension else if (ConfigColumnAction.LessThanOrEqual.ToString().Equals(filterCondition.ColumnAction)) { if (ConfigColumnDataType.type_int.ToString() == filterCondition.ColumnDataType - || ConfigColumnDataType.type_decimal.ToString() == filterCondition.ColumnDataType + || ConfigColumnDataType.type_decimal.ToString() == filterCondition.ColumnDataType || ConfigColumnDataType.type_datetime.ToString() == filterCondition.ColumnDataType) return Expression.Lambda>(Expression.LessThanOrEqual(member, constant), parameter); else