コード例 #1
0
        private void AppendPath(ODataPath path)
        {
            Debug.Assert(path != null);

            ODataPathKind kind = path.Kind;

            switch (kind)
            {
            case ODataPathKind.ComplexProperty:
            case ODataPathKind.TypeCast:
            case ODataPathKind.DollarCount:
            case ODataPathKind.Entity:
            case ODataPathKind.EntitySet:
            case ODataPathKind.Singleton:
            case ODataPathKind.MediaEntity:
                if (path.FirstSegment is ODataNavigationSourceSegment navigationSourceSegment)
                {
                    if (!_allNavigationSourcePaths.TryGetValue(navigationSourceSegment.EntityType, out IList <ODataPath> nsList))
                    {
                        nsList = new List <ODataPath>();
                        _allNavigationSourcePaths[navigationSourceSegment.EntityType] = nsList;
                    }
                    nsList.Add(path);
                }
                break;

            case ODataPathKind.NavigationProperty:
            case ODataPathKind.Ref:
                ODataNavigationPropertySegment navigationPropertySegment = path.OfType <ODataNavigationPropertySegment>().Last();

                if (!_allNavigationPropertyPaths.TryGetValue(navigationPropertySegment.EntityType, out IList <ODataPath> npList))
                {
                    npList = new List <ODataPath>();
                    _allNavigationPropertyPaths[navigationPropertySegment.EntityType] = npList;
                }

                npList.Add(path);
                break;

            case ODataPathKind.Operation:
            case ODataPathKind.OperationImport:
                _allOperationPaths.Add(path);
                break;

            default:
                return;
            }
        }
コード例 #2
0
        private bool AppendBoundOperationOnNavigationPropertyPath(IEdmOperation edmOperation, bool isCollection, IEdmEntityType bindingEntityType)
        {
            bool found             = false;
            bool isEscapedFunction = _model.IsUrlEscapeFunction(edmOperation);

            if (_allNavigationPropertyPaths.TryGetValue(bindingEntityType, out IList <ODataPath> value))
            {
                foreach (var path in value)
                {
                    if (path.Kind == ODataPathKind.Ref)
                    {
                        continue;
                    }

                    ODataNavigationPropertySegment npSegment = path.Segments.Last(s => s is ODataNavigationPropertySegment) as ODataNavigationPropertySegment;

                    bool isLastKeySegment = path.LastSegment is ODataKeySegment;

                    if (isCollection)
                    {
                        if (isLastKeySegment)
                        {
                            continue;
                        }

                        if (npSegment.NavigationProperty.TargetMultiplicity() != EdmMultiplicity.Many)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!isLastKeySegment && npSegment.NavigationProperty.TargetMultiplicity() == EdmMultiplicity.Many)
                        {
                            continue;
                        }
                    }

                    ODataPath newPath = path.Clone();
                    newPath.Push(new ODataOperationSegment(edmOperation, isEscapedFunction));
                    AppendPath(newPath);
                    found = true;
                }
            }

            return(found);
        }
コード例 #3
0
        private void AppendPath(ODataPath path)
        {
            Debug.Assert(path != null);

            ODataPathKind kind = path.Kind;

            switch (kind)
            {
            case ODataPathKind.Entity:
            case ODataPathKind.EntitySet:
            case ODataPathKind.Singleton:
                ODataNavigationSourceSegment navigationSourceSegment = (ODataNavigationSourceSegment)path.FirstSegment;
                if (!_allNavigationSourcePaths.TryGetValue(navigationSourceSegment.EntityType, out IList <ODataPath> nsList))
                {
                    nsList = new List <ODataPath>();
                    _allNavigationSourcePaths[navigationSourceSegment.EntityType] = nsList;
                }

                nsList.Add(path);
                break;

            case ODataPathKind.NavigationProperty:
                ODataNavigationPropertySegment navigationPropertySegment = path.Last(p => p is ODataNavigationPropertySegment)
                                                                           as ODataNavigationPropertySegment;

                if (!_allNavigationPropertyPaths.TryGetValue(navigationPropertySegment.EntityType, out IList <ODataPath> npList))
                {
                    npList = new List <ODataPath>();
                    _allNavigationPropertyPaths[navigationPropertySegment.EntityType] = npList;
                }

                npList.Add(path);
                break;

            case ODataPathKind.Operation:
            case ODataPathKind.OperationImport:
                _allOperationPaths.Add(path);
                break;

            default:
                return;
            }
        }