src/openCypherParser/AST/CypherVisitor.cs
/// <summary>
/// Helper update in-place the Entity Type for any QueryExpressionProperty potentially referring to an entity
/// nested in a list of QueryExpression roots
/// </summary>
/// <param name="exprsToUpdate">list of QueryExpression that may contain QueryExpressionProperty inside</param>
/// <param name="entities">a mapping of entity type to alias</param>
/// <returns></returns>
Helper update in-place the Entity Type for any QueryExpressionProperty potentially referring to an entity
nested in a list of QueryExpression roots
Helper update in - place the Entity Type for any QueryExpressionProperty potentially referring to an entity nested in a list of QueryExpression roots
private void UpdateEntityTypesInExpressionInPlace(IEnumerable<QueryExpression> exprsToUpdate, IEnumerable<Entity> entities)
        {
            var projectionExprsReferingEntities = exprsToUpdate
                .SelectMany(e => e.GetChildrenQueryExpressionType<QueryExpressionProperty>())
                .Cast<QueryExpressionProperty>()
                .Where(p => string.IsNullOrEmpty(p.PropertyName))
                .ToList();
            projectionExprsReferingEntities.ForEach(e =>
            {
                var entityMatchedAlias = entities.FirstOrDefault(e2 => e2.Alias == e.VariableName);
                if (entityMatchedAlias != null)
                {
                    e.Entity = entityMatchedAlias.Clone();
                }
            });
        }
private void UpdateEntityTypesInExpressionInPlace ( IEnumerable < QueryExpression > exprsToUpdate , IEnumerable < Entity > entities ) { var projectionExprsReferingEntities = exprsToUpdate . SelectMany ( e => e . GetChildrenQueryExpressionType < QueryExpressionProperty > ( ) ) . Cast < QueryExpressionProperty > ( ) . Where ( p => string . IsNullOrEmpty ( p . PropertyName ) ) . ToList ( ) ; projectionExprsReferingEntities . ForEach ( e => { var entityMatchedAlias = entities . FirstOrDefault ( e2 => e2 . Alias == e . VariableName ) ; if ( entityMatchedAlias != null ) { e . Entity = entityMatchedAlias . Clone ( ) ; } } ) ; }
Helper update in-place the Entity Type for any QueryExpressionProperty potentially referring to an entity
nested in a list of QueryExpression roots
Helper update in - place the Entity Type for any QueryExpressionProperty potentially referring to an entity nested in a list of QueryExpression roots
// make best-effort in-place update for any alias with an entity match // for any that did not match, it is either a reference to a value alias // or a dangling alias - which will trigger exception down the line
None
exprsToUpdate
IEnumerable<QueryExpression>
list of QueryExpression that may contain QueryExpressionProperty inside
list of QueryExpression that may contain QueryExpressionProperty inside
entities
IEnumerable<Entity>
a mapping of entity type to alias
a mapping of entity type to alias