Exemplo n.º 1
0
        public Expression BuildSelect(SelectExpandClause selectClause, Expression source, bool navigationNextLink, bool skipToken)
        {
            foreach (SelectItem selectItemClause in selectClause.SelectedItems)
            {
                var          selectItemTranslator = new OeSelectItemTranslator(_navigationItem, navigationNextLink, source, _joinBuilder, skipToken);
                OeSelectItem selectItem           = selectItemClause.TranslateWith(selectItemTranslator);
                if (selectItem != null)
                {
                    if (selectItem.EdmProperty is IEdmNavigationProperty)
                    {
                        source = selectItemTranslator.Source;
                    }
                    else
                    {
                        _navigationItem.AddSelectItem(selectItem);
                    }
                }
            }

            if (_navigationItem.SelectItems.Count > 0)
            {
                AddKey(_metadataLevel != OeMetadataLevel.Full);
            }

            return(source);
        }
Exemplo n.º 2
0
        private static Expression BuildOrderBySkipToken(OeSelectItem navigationItem, OrderByClause orderByClause, Expression source, OeJoinBuilder joinBuilder, bool hasSelectItems)
        {
            while (orderByClause != null)
            {
                var propertyNode = (SingleValuePropertyAccessNode)orderByClause.Expression;
                if (propertyNode.Source is SingleNavigationNode navigationNode)
                {
                    OeSelectItem match = null;
                    ExpandedNavigationSelectItem navigationSelectItem = null;
                    do
                    {
                        if ((match = navigationItem.FindHierarchyNavigationItem(navigationNode.NavigationProperty)) != null)
                        {
                            match.AddSelectItem(new OeSelectItem(propertyNode.Property, true));
                            break;
                        }

                        SelectExpandClause selectExpandClause;
                        if (navigationSelectItem == null)
                        {
                            var pathSelectItem = new PathSelectItem(new ODataSelectPath(new PropertySegment((IEdmStructuralProperty)propertyNode.Property)));
                            selectExpandClause = new SelectExpandClause(new[] { pathSelectItem }, false);
                        }
                        else
                        {
                            selectExpandClause = new SelectExpandClause(new[] { navigationSelectItem }, false);
                        }

                        var segment = new NavigationPropertySegment(navigationNode.NavigationProperty, navigationNode.NavigationSource);
                        navigationSelectItem = new ExpandedNavigationSelectItem(new ODataExpandPath(segment), navigationNode.NavigationSource, selectExpandClause);
                    }while ((navigationNode = navigationNode.Source as SingleNavigationNode) != null);

                    if (navigationSelectItem != null)
                    {
                        if (match == null)
                        {
                            match = navigationItem;
                        }

                        var selectItemTranslator = new OeSelectItemTranslator(match, false, source, joinBuilder, true);
                        navigationSelectItem.TranslateWith(selectItemTranslator);
                        source = selectItemTranslator.Source;
                    }
                }
                else
                {
                    if (hasSelectItems)
                    {
                        navigationItem.AddSelectItem(new OeSelectItem(propertyNode.Property, true));
                    }
                }

                orderByClause = orderByClause.ThenBy;
            }

            return(source);
        }
Exemplo n.º 3
0
        public void BuildSelect(SelectExpandClause selectClause, OeMetadataLevel metadataLevel)
        {
            if (selectClause != null)
            {
                var selectItemTranslator = new OeSelectItemTranslator(_edmModel, false);
                foreach (SelectItem selectItemClause in selectClause.SelectedItems)
                {
                    selectItemTranslator.Translate(_rootNavigationItem, selectItemClause);
                }
            }

            _rootNavigationItem.AddKeyRecursive(metadataLevel != OeMetadataLevel.Full);
        }
Exemplo n.º 4
0
        private void BuildOrderBySkipTake(OeNavigationSelectItem navigationItem, OrderByClause orderByClause, bool hasSelectItems)
        {
            while (orderByClause != null)
            {
                var propertyNode = (SingleValuePropertyAccessNode)orderByClause.Expression;
                if (propertyNode.Source is SingleNavigationNode navigationNode)
                {
                    OeNavigationSelectItem?      match;
                    ExpandedNavigationSelectItem?navigationSelectItem = null;
                    for (; ;)
                    {
                        if ((match = navigationItem.FindHierarchyNavigationItem(navigationNode.NavigationProperty)) != null)
                        {
                            match.AddStructuralItem((IEdmStructuralProperty)propertyNode.Property, true);
                            break;
                        }

                        SelectExpandClause selectExpandClause;
                        if (navigationSelectItem == null)
                        {
                            var pathSelectItem = new PathSelectItem(new ODataSelectPath(new PropertySegment((IEdmStructuralProperty)propertyNode.Property)));
                            selectExpandClause = new SelectExpandClause(new[] { pathSelectItem }, false);
                        }
                        else
                        {
                            selectExpandClause = new SelectExpandClause(new[] { navigationSelectItem }, false);
                        }

                        var segment = new NavigationPropertySegment(navigationNode.NavigationProperty, navigationNode.NavigationSource);
                        navigationSelectItem = new ExpandedNavigationSelectItem(new ODataExpandPath(segment), navigationNode.NavigationSource, selectExpandClause);

                        if (navigationNode.Source is SingleNavigationNode singleNavigationNode)
                        {
                            navigationNode = singleNavigationNode;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (navigationSelectItem != null)
                    {
                        if (match == null)
                        {
                            match = navigationItem;
                        }

                        var selectItemTranslator = new OeSelectItemTranslator(_edmModel, true);
                        selectItemTranslator.Translate(match, navigationSelectItem);
                    }
                }
                else
                {
                    if (hasSelectItems)
                    {
                        navigationItem.AddStructuralItem((IEdmStructuralProperty)propertyNode.Property, true);
                    }
                }

                orderByClause = orderByClause.ThenBy;
            }
        }