示例#1
0
        private static ODataSelectPath BuildSelectPath(SelectModelPath path, IEdmNavigationSource navigationSource)
        {
            IList <ODataPathSegment> segments = new List <ODataPathSegment>();
            IEdmType previousPropertyType     = null;

            foreach (var node in path)
            {
                if (node is IEdmStructuralProperty property)
                {
                    segments.Add(new PropertySegment(property));
                    previousPropertyType = property.Type.GetElementType();
                }
                else if (node is IEdmStructuredType typeNode)
                {
                    if (previousPropertyType == null)
                    {
                        segments.Add(new TypeSegment(typeNode, navigationSource));
                    }
                    else
                    {
                        segments.Add(new TypeSegment(typeNode, previousPropertyType, navigationSource));
                    }
                }
            }

            return(new ODataSelectPath(segments));
        }
        public void Ctor_SelectModelPath_WithBasicElements_SetsProperties()
        {
            // Arrange
            IList <IEdmElement> elements = new List <IEdmElement>
            {
                _homeAddress
            };

            // Act
            SelectModelPath selectPath = new SelectModelPath(elements);

            // Assert
            Assert.Equal("HomeAddress", selectPath.SelectPath);
        }