Microsoft Json 规则引擎自定义错误消息

时间:2021-07-06 09:13:46

标签: c# rule-engine business-rules

我将以下库用于 json 基本规则引擎。 https://github.com/microsoft/RulesEngine

我想将属性值连接到错误消息中。我有一个集合列表,我想连接列表中满足表达式条件的项目。

{
        "RuleName": "CheckforVTPumpSelectionErrors121-03",
        "ErrorMessage": "WARNING: 121 - VT PUMP Manual Pick Required for {0} HP {1} pump!",
         "Expression": "ProductFamily.PumpConfigurations.Any(r => r.PumpDescription == \"Water Feature\" || r.PumpDescription == \"Transfer\") && Flag1 == false"
}

我想用马力值替换 {0}。

我的 DTO:

public class ProductFamily
    {
        public int SCCR = 30;
        public List<PumpConfiguration> PumpConfigurations { get; set; }
    }

 public class PumpConfiguration
    {
        public PumpConfiguration()
        {
        }
        public string PumpDescription { get; internal set; }
        public int HP { get; internal set; }
    }

0 个答案:

没有答案
相关问题