Description
I'm trying to do a graph lookup, but it looks like the C# API doesn't agree with my thinking here:
class Node |
{
|
string Id { get; set; }
|
List<string> ParentIds { get; set; }
|
}
|
|
|
class NodeWithChildren |
{
|
Node[] Children { get; set; }
|
}
|
|
|
var query = collection.Aggregate()
|
.GraphLookup(
|
from: collection,
|
connectFromField: x => x.Id,
|
connectToField: x => x.ParentIds,
|
startWith: x => x.Id,
|
@as: (NodeWithChildren x) => x.Children); |
This throws:
|
ArgumentException: TConnectFrom must be either TConnectTo or a type that implements IEnumerable<TConnectTo>. |
Parameter name: TConnectFrom
|
While the query should work fine:
db.Node.aggregate([
|
{ $graphLookup: { from: 'Node', startWith: "$_id", connectFromField: "_id", connectToField: "ParentIds", as: "Children" } } |
])
|