yojimbo87 / ArangoDB-NET

C#/.NET/Mono driver for ArangoDB
MIT License
107 stars 66 forks source link

LINQ? #42

Open francnuec opened 7 years ago

francnuec commented 7 years ago

Any support for LINQ planned?

yojimbo87 commented 7 years ago

I worked on a prototype some time ago which used fluent API to generate AQL queries. I think the main problem is that flexibility of AQL allows you to construct large and complex queries, e.g. in terms of nesting, and thus there are number of issues related to how the structure of complex query should be represented in C#. For example it can be rather easy to come up with C# representation for something like this:

FOR item IN MyCollection
    FILTER item.field == 'xyz'
    RETURN item

However what about something more complex like this:

FOR category IN categories
    FOR e_subCatTag IN EDGES(e_has_t, eventID, 'inbound')
        LET subCatTag = DOCUMENT(e_subCatTag._from)
        FILTER subCatTag.Property == 'SubCategory' && subCatTag.ParentValue == category.title && subCatTag.I_EntityState == 1
        FOR e_catTag IN EDGES(e_has_t, eventID, 'inbound')
            LET catTag = DOCUMENT(e_catTag._from)
            FILTER catTag.Property == 'Category' && catTag.ParentValue == subCatTag.Value && catTag.I_EntityState == 1
            FOR e_item IN EDGES(tagged, catTag._id, 'outbound')
                FOR e_stand IN EDGES(s_has_i, e_item._to, 'outbound')
                    COLLECT standID = e_stand._to
                    RETURN standID

Query above is still relatively "easy" given the fact that you can construct AQL query which will have hundreds of lines (why would you construct such a long query is another topic, but the possibility of doing it is still there). This brings questions, such as how the fluent API should handle nesting, so that visually, resulting C# representation isn't messy and provides advantages over raw AQL (e.g. in terms of intellisense support).

Anyway I'm open for suggestions and ideas how people would like to have their AQL queries represented in C#.