diff --git a/Jinget.Core/Utilities/Expressions/ExpressionUtility.cs b/Jinget.Core/Utilities/Expressions/ExpressionUtility.cs index 73e08b5..d7007eb 100644 --- a/Jinget.Core/Utilities/Expressions/ExpressionUtility.cs +++ b/Jinget.Core/Utilities/Expressions/ExpressionUtility.cs @@ -159,20 +159,37 @@ public static Expression> CreateMemberInitExpression(string parame return Expression.Lambda>(memberinit, paramExpression); } - public static Expression> ConstructBinaryExpression(object? json, bool treatNullAsTrueCondition = true) + /// + /// Construct a boolean expression based on a json input + /// + /// + /// a key/value structured json string/object, where keys are types property and values are their value + /// When is null or empty, then a default condition will be returned. + /// if this parameter's value is set to true the a default true condition will be returned otherwise a defaule false condition will be returned + /// + public static Expression> ConstructBinaryExpression(object? json, bool treatNullOrEmptyAsTrueCondition = true) { if (json is null) { - return treatNullAsTrueCondition ? BooleanUtility.TrueCondition() : BooleanUtility.FalseCondition(); + return treatNullOrEmptyAsTrueCondition ? BooleanUtility.TrueCondition() : BooleanUtility.FalseCondition(); } else - return ConstructBinaryExpression(json.ToString(), treatNullAsTrueCondition); + return ConstructBinaryExpression(json.ToString(), treatNullOrEmptyAsTrueCondition); } - public static Expression> ConstructBinaryExpression(string json, bool treatNullAsTrueCondition = true) + + /// + /// Construct a boolean expression based on a json input + /// + /// + /// a key/value structured json string/object, where keys are types property and values are their value + /// When is null or empty, then a default condition will be returned. + /// if this parameters value is set to true the a default true condition will be returned otherwise a defaule false condition will be returned + /// + public static Expression> ConstructBinaryExpression(string json, bool treatNullOrEmptyAsTrueCondition = true) { if (string.IsNullOrWhiteSpace(json.ToString())) { - return treatNullAsTrueCondition ? BooleanUtility.TrueCondition() : BooleanUtility.FalseCondition(); + return treatNullOrEmptyAsTrueCondition ? BooleanUtility.TrueCondition() : BooleanUtility.FalseCondition(); } var filters = JsonConvert.DeserializeObject>(json); @@ -180,10 +197,10 @@ public static Expression> ConstructBinaryExpression(string json var type = typeof(T); var exprVar = Expression.Parameter(type, "x"); - //if there is no filter specified, then return a true condition + //if there is no filter specified, then return the default true/false condition if (filters == null || !filters.Any()) { - return BooleanUtility.TrueCondition(); + return treatNullOrEmptyAsTrueCondition ? BooleanUtility.TrueCondition() : BooleanUtility.FalseCondition(); } //construct queries