How does the NRules Engine locate facts?

Skip to first unread message

Mike Doonsebury

Mar 12, 2019, 8:27:17 PM3/12/19
to NRules Users
I put facts into the Working Set using the this.session.Insert(object fact1) or this.session.InsertAll(IEnumerable<object> fact) methods.  Now, one of the facts changes and I call the this.session.Replace(object fact).
How does NRules know which object to replace?  Does it compare the references for equality?  Does it call the Equals operator?  I'm guessing you're probably using Dictionary logic, so the object's Equals() and GetHashCode() determine when two facts are equal, but I need some affirmation before I continue with my design.

Did I miss this discussion in the documentation?

Sergiy Nikolayev

Mar 12, 2019, 9:25:42 PM3/12/19
to NRules Users
You are right, the engine looks for existing facts using Object.Equals, and does indeed require a proper corresponding implementation of GetHashCode.
Reply all
Reply to author
0 new messages