-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fluent interface #22
Comments
So I don't ever write the rules in code but instead have more of a query builder web UI that I use to build them but as far as syntax goes I'd vote foe B as it seems similar to they syntax in other libraries I've used such as that of the MongoDB QueryBuilder. |
Funny, my other project was to create a desktop app to create Rules. Do you have a Rules Collection class?
|
I would also go for B or change Create to Target |
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.
The text was updated successfully, but these errors were encountered: