-
Notifications
You must be signed in to change notification settings - Fork 75
Description
I've been working on a alternate fluent/expression interface for creating rules. Basically, what you'd now write as
Rule rule = Rule.Create("Status", mreOperator.Equal, Status.Open);
you could now write as
Rule rule = Rule<Order>.Create(x=>x.Status).Equals(Status.Open);
By specifying the member as a lambda function, it verifies at coding time that the property exists on the source object, and even gives you Intellisense so you can't misspell it. It also verifies that the target value is the right type. (And it produces standard Rule objects, so you can mix & match the different syntaxes)
So, syntax question: Which do you prefer??
A) Rule rule = Rule<Order>.Create(x=>x.Status).Equals(Status.Open);
B) Rule rule = Rule<Order>.Equals(x=>x.Status, Status.Open);
One part of me prefers the shorter syntax of B), but another part prefers the way A have the operation between the member and the target.