Esempio n. 1
0
 public QupidQuery(PropertyList pl, string collection, List<WhereClause> where, UnwindClause unwind, 
     GroupByClause groupBy, HavingClause have, WithClause with)
 {
     CollectionName = collection;
     SelectProperties = pl;
     WhereClauses = where;
     UnwindClause = unwind;
     GroupByClause = groupBy;
     HavingClause = have;
     WithClause = with;
 }
Esempio n. 2
0
        private void AnalyzeSelectList(QupidCollection collection, PropertyList propertyList)
        {
            if (propertyList == null || propertyList.Properties == null)
            {
                return;
            }

            foreach (var prop in propertyList.Properties.ToArray())
            {
                if (!prop.Collection.Equals(collection.Name, StringComparison.OrdinalIgnoreCase))
                {
                    // skip over selected properties from "with" tables/collections
                    continue;
                }
                if (prop.IsAggregate)
                {
                    continue;
                }
                if (prop.Path == "*")
                {
                    // expand '*' property references to include everything within that nesting level
                    var expandedProperties = collection.GetAllReferencedProperties(prop.Path);
                    if (expandedProperties == null)
                    {
                        _compiler.ErrorManager.AddWarning("The 'select' property (" + prop.Path + ") is invalid.", prop.Line, prop.Character);
                        continue;
                    }

                    // add all expanded properties
                    propertyList.Properties.AddRange(expandedProperties.Select(qp => new PropertyReference(collection.Name, qp.LongName, prop.Line, prop.Character)
                        {
                            AnalyzedName = qp.ShortName,
                        }));

                    // pull out the '.*' property
                    propertyList.Properties.Remove(prop);
                    continue;
                }

                var shortName = collection.ConvertToShortPath(prop.Path);
                if (shortName == null)
                {
                    _compiler.ErrorManager.AddWarning("The 'select' property (" + prop.Path + ") is invalid.", prop.Line, prop.Character);
                    continue;
                }
                prop.AnalyzedName = shortName;
            }
        }