Objective-c – Is there something similar to LINQ in Objective-C

databaseobjective-c

I wonder if it is possible (and how) to provide a class in Objective-C with something like:

Person.Select(@"Name").OrderAsc(@"Name").Where(@"Id").EqualTo(1).And(@"Id").NotEqualTo(2).Load<Array>

That could be very handy for a project I'm doing.

I like this way of coding present in Django & SubSonic.

Best Solution

I created my own Linq-style API for Objective C, which is available on github. Your specific example would look something like this:

NSArray* results = [[[people where:^BOOL(id person) {
                                return [person id] == 1 && [person id] != 2;
                             }]
                             select:^id(id person) {
                                return [person name];
                             }]
                             sort];