MonkeyBonkey
MonkeyBonkey

Reputation: 47921

how to return an ICollection<T> with the .net neo4j Client

I'm trying to return a result list from my cypher query using the .net neo4j client and getting a "Does not contain a definition for ToList()" error. Am I doing this incorrectly?

public async ICollection<App> getWishList(string uname)
{

    var query = client.Cypher.StartWithNodeIndexLookup("root", AUTOINDEX, PRIMARYINDEX, uname)
        .Match("root-[:WishList]-apps")
        .Return<ICollection<App>>("apps");

    var results = await query.ResultsAsync;
    return results.ToList<App>();

}

Upvotes: 0

Views: 371

Answers (1)

MonkeyBonkey
MonkeyBonkey

Reputation: 47921

Ok, it was a simple answer.

I need to set the return type to just "App" instead of "ICollection" since the query already returns a collection.

var query = client.Cypher.StartWithNodeIndexLookup("root", AUTOINDEX, PrimaryIndexKey, uname)
            .Match("root-[:WishList]-apps")
            .Return<App>("apps");

        var results = await query.ResultsAsync;
        return results.ToList();

Upvotes: 3

Related Questions