Ejemplo n.º 1
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;
                    do
                    {
                        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);
                    }while ((navigationNode = navigationNode.Source as SingleNavigationNode) != null);

                    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;
            }
        }
Ejemplo n.º 2
0
 private void BuildCompute(ComputeClause computeClause)
 {
     if (computeClause != null)
     {
         foreach (ComputeExpression computeExpression in computeClause.ComputedItems)
         {
             Expression        expression       = _joinBuilder.Visitor.TranslateNode(computeExpression.Expression);
             IEdmTypeReference edmTypeReference = OeEdmClrHelper.GetEdmTypeReference(_edmModel, expression.Type);
             var computeProperty = new ComputeProperty(computeExpression.Alias, edmTypeReference, expression);
             _rootNavigationItem.AddStructuralItem(computeProperty, false);
         }
     }
 }
        private void Translate(OeNavigationSelectItem parentNavigationItem, PathSelectItem item)
        {
            if (item.SelectedPath.LastSegment is NavigationPropertySegment navigationSegment)
            {
                IEdmNavigationSource navigationSource = navigationSegment.NavigationSource;
                if (navigationSource == null)
                {
                    navigationSource = OeEdmClrHelper.GetEntitySet(_edmModel, navigationSegment.NavigationProperty);
                }

                var expandedItem = new ExpandedNavigationSelectItem(new ODataExpandPath(item.SelectedPath), navigationSource, new SelectExpandClause(null, true));
                AddOrGetNavigationItem(parentNavigationItem, expandedItem, false);
            }
            else if (item.SelectedPath.LastSegment is PropertySegment propertySegment)
            {
                parentNavigationItem.AddStructuralItem(propertySegment.Property, _notSelected);
            }
            else
            {
                throw new InvalidOperationException(item.SelectedPath.LastSegment.GetType().Name + " not supported");
            }
        }