Object Generation by combination

Jan 19, 2011 at 2:54 PM
Edited Jan 19, 2011 at 3:04 PM

First of all, great project! 

My idea:

What about an additional way to generate objects using combinations? (similar to all-pairs)

                       Combine(Func<T, TMember> property, params TMember[] values);

Sample usage being something like this:

                      IList<SimpleUser> users = session.List<SimpleUser>()
                            .Combine(x => x.FirstName, "Bob", "Joe", "Mike")
                                                                           .Combine(x => x.LastName, "Smith", "Jones")
                                                                           .All(x => x.Age, 30)
Resulting in 6 objects (3x2):
{"Bob", "Smith", 30}
{"Bob", "Jones", 30}
{"Joe", "Smith", 30}
{"Joe", "Jones", 30}
{"Mike", "Smith", 30}
{"Mike", "Jones", 30}
*Notice the size parameter of "List" is absent since the combinations are now in control of the number of objects. (this does have some impact on "First"/"Next" usage I realize, but perhaps this is a separate interface?)

Of course, obtaining this result set is possible with the current api.  The problem comes in, however, with testing very complex objects.  Creating all possible combinations of say 10 separate values, where each is an enumeration, results in some unwieldy code!
Jan 19, 2011 at 2:57 PM

I believe somebody submitted a pull request along these lines not long ago, this is a slightly different take on that idea - I'll add it to the issue queue and get it dealt with :-)