private Func <IDataReader, TItem> CompileForEnumerate <TItem>(TableIdentity heading)
        {
            this.variables = new VariableStore();

            ItemBuilder   builder       = new ItemBuilder(this.State.Schema, heading);
            EnumerateNode enumerateNode = builder.Build();
            MetadataNode  resultNode    = enumerateNode.Items.FirstOrDefault(n => n.HasFlag(NodeFlags.Result));

            if (resultNode == null)
            {
                return(r => default);
Exemple #2
0
        public ResultNode Build()
        {
            this.PreserveIndices();

            ItemBuilder   itemBuilder   = new ItemBuilder(this.Schema, this.Table);
            EnumerateNode enumerateNode = itemBuilder.Build();

            IList <MetadataNode> itemNodes    = this.GetItemNodes(enumerateNode).ToList();
            IList <ElementNode>  elementNodes = this.GetElementNodes(itemNodes).ToList();
            IList <ListNode>     listNodes    = this.GetListNodes(elementNodes).ToList();
            IList <ListNode>     dictNodes    = this.GetDictionaryNodes(elementNodes).ToList();

            this.AddAggregateTargets(elementNodes);

            return(new ResultNode()
            {
                Lists = listNodes.Concat(dictNodes).ToList(),
                Elements = elementNodes,
                Helpers = enumerateNode.Helpers,
            });
        }
Exemple #3
0
        private IEnumerable <MetadataNode> GetItemNodes(EnumerateNode enumerateNode)
        {
            List <MetadataNode> itemNodes = enumerateNode.Items.ToList();
            List <MetadataNode> allNodes  = itemNodes.SelectMany(n => n.Tree()).Except(itemNodes).ToList();
            List <MetadataNode> fakeNodes = allNodes.Where(n => this.HasManyAttribute(n.Metadata)).ToList();

            foreach (MetadataNode itemNode in fakeNodes)
            {
                MetadataNode parentNode = this.FindNode(itemNodes, itemNode.Metadata.Parent);

                if (parentNode != null)
                {
                    parentNode.Properties.Remove(itemNode);
                    itemNodes.Insert(0, itemNode);
                }
            }

            foreach (MetadataNode itemNode in itemNodes.Where(this.HasValue))
            {
                yield return(itemNode);
            }
        }