protected internal virtual Expression VisitGroupJoin(GroupJoinExpression node) { return(node.Update( Visit(node.Source), Visit(node.Joined), Visit(node.SourceKeySelector), Visit(node.JoinedKeySelector))); }
private void TranslateGroupJoin(GroupJoinExpression node) { Translate(node.Source); var joined = node.Joined as CollectionExpression; if (joined == null) { throw new NotSupportedException("Only a collection is allowed to be joined."); } var localFieldValue = AggregateLanguageTranslator.Translate(node.SourceKeySelector); if (localFieldValue.BsonType != BsonType.String) { throw new NotSupportedException("Could not translate the local field."); } var localField = localFieldValue.ToString().Substring(1); // remove '$' var foreignFieldValue = AggregateLanguageTranslator.Translate(node.JoinedKeySelector); if (foreignFieldValue.BsonType != BsonType.String) { throw new NotSupportedException("Could not translate the foreign field."); } var foreignField = foreignFieldValue.ToString().Substring(1); // remove '$' _stages.Add(new BsonDocument("$lookup", new BsonDocument { { "from", ((CollectionExpression)node.Joined).CollectionNamespace.CollectionName }, { "localField", localField }, { "foreignField", foreignField }, { "as", node.JoinedItemName } })); }
protected internal virtual Expression VisitGroupJoin(GroupJoinExpression node) { return node.Update( Visit(node.Source), Visit(node.Joined), Visit(node.SourceKeySelector), Visit(node.JoinedKeySelector)); }