microsoft / RulesEngine

A Json based Rules Engine with extensive Dynamic expression support
https://microsoft.github.io/RulesEngine/
MIT License
3.47k stars 528 forks source link

Dictionary type supports .? #595

Open zhenlei520 opened 3 months ago

zhenlei520 commented 3 months ago

If I introduce a value of type Dictionary<string,string>, I can use . in Expression to get the value of the specified key.

For example: My rule engine type is

{
     public Dictionary<string, string> Dimensions { get; set; }
}

where the value of Dimensions is

{"name":"tony"}

According to my understanding Expression should be

metadata.Dimensions.Any(d=>d.Key=="snakeTest" && d.Value=="tony")

However, during actual use, I found that it is also feasible to write as follows metadata.Dimensions.name == "tony"

Why is this happening? Does RulesEngine do any special processing?

asulwer commented 1 week ago

you need to register IEnumerable so that Any can work