I'm looking for a working example of dynamic NRules. Actually, I want to write the rules in a notepad file and want to read them at runtime.
I have been searching it through the internet for last 4 days but didn't find anything.
Any help is appreciable.
NRules is primarily positioned as a rules engine where rules are authored in C#, and compiled into assemblies. There is a companion project https://github.com/NRules/NRules.Language that defines a textual DSL (called Rule#) for expressing rules. It's less feature-complete than C# DSL, but is potentially what you are looking for.
You would still have a project in C# that loads the textual rules from the file system or a DB, and drives the rules engine. You would use https://www.nuget.org/packages/NRules.RuleSharp package for parsing the textual rules into a rule model, and https://www.nuget.org/packages/NRules.Runtime to compile the rule model into an executable form and run the rules.
Given a domain model:
And given a text file with rules called
MyRuleFile.txt:Here is an example of how the rules driver code might look like:
Output: