Esempio n. 1
0
        /// <summary>
        /// Gets all the nested properties of a structural type recursively.
        /// </summary>
        /// <param name="structuralType">The type from which to extra properties.</param>
        /// <param name="operationFilter">The filter to apply based on supported operations of each property.</param>
        /// <param name="navigationPropertyFilter">The filter to apply based on whether or not to select navigation properties.</param>
        /// <returns>A list of string arrays representing the property paths to each property (including nested properties) in the entity.</returns>
        protected IEnumerable<string[]> GetAllNestedPropertyPaths(QueryStructuralType structuralType, SupportOperationsFilter operationFilter, NavigationPropertyFilter navigationPropertyFilter)
        {
            IList<string[]> allPropertyPaths = new List<string[]>();

            foreach (var property in structuralType.Properties)
            {
                var propertyType = property.PropertyType;
                var qst = propertyType as QueryScalarType;
                var qcxt = propertyType as QueryComplexType;
                var qct = propertyType as QueryCollectionType;

                if (qst != null)
                {
                    if (operationFilter == SupportOperationsFilter.NoFilter ||
                        (operationFilter == SupportOperationsFilter.ArithmeticOperable && this.SupportsArithmeticOperations(qst)) ||
                        (operationFilter == SupportOperationsFilter.EqualComparable && qst.SupportsEqualityComparison) ||
                        (operationFilter == SupportOperationsFilter.OrderComparable && qst.SupportsOrderComparison))
                    {
                        if (navigationPropertyFilter != NavigationPropertyFilter.NavigationOnly)
                        {
                            allPropertyPaths.Add(new string[] { property.Name });
                        }
                    }
                }
                else if (qcxt != null)
                {
                    // For complex types recursively find child properties and add them to the list of property paths.
                    var nestedTypePaths = this.GetAllNestedPropertyPaths(qcxt, operationFilter, navigationPropertyFilter);

                    foreach (var nestedTypePath in nestedTypePaths)
                    {
                        var propertyPath = new string[] { property.Name };
                        propertyPath = propertyPath.Concat(nestedTypePath).ToArray();

                        if (navigationPropertyFilter != NavigationPropertyFilter.NavigationOnly)
                        {
                            allPropertyPaths.Add(propertyPath);
                        }
                    }
                }
                else if (qct != null)
                {
                    if (navigationPropertyFilter != NavigationPropertyFilter.NonNavigationOnly)
                    {
                        allPropertyPaths.Add(new string[] { property.Name });
                    }
                }
            }

            return allPropertyPaths.AsEnumerable();
        }
Esempio n. 2
0
        /// <summary>
        /// Gets all the nested properties of a structural type recursively.
        /// </summary>
        /// <param name="structuralType">The type from which to extra properties.</param>
        /// <param name="operationFilter">The filter to apply based on supported operations of each property.</param>
        /// <param name="navigationPropertyFilter">The filter to apply based on whether or not to select navigation properties.</param>
        /// <returns>A list of string arrays representing the property paths to each property (including nested properties) in the entity.</returns>
        protected IEnumerable <string[]> GetAllNestedPropertyPaths(QueryStructuralType structuralType, SupportOperationsFilter operationFilter, NavigationPropertyFilter navigationPropertyFilter)
        {
            IList <string[]> allPropertyPaths = new List <string[]>();

            foreach (var property in structuralType.Properties)
            {
                var propertyType = property.PropertyType;
                var qst          = propertyType as QueryScalarType;
                var qcxt         = propertyType as QueryComplexType;
                var qct          = propertyType as QueryCollectionType;

                if (qst != null)
                {
                    if (operationFilter == SupportOperationsFilter.NoFilter ||
                        (operationFilter == SupportOperationsFilter.ArithmeticOperable && this.SupportsArithmeticOperations(qst)) ||
                        (operationFilter == SupportOperationsFilter.EqualComparable && qst.SupportsEqualityComparison) ||
                        (operationFilter == SupportOperationsFilter.OrderComparable && qst.SupportsOrderComparison))
                    {
                        if (navigationPropertyFilter != NavigationPropertyFilter.NavigationOnly)
                        {
                            allPropertyPaths.Add(new string[] { property.Name });
                        }
                    }
                }
                else if (qcxt != null)
                {
                    // For complex types recursively find child properties and add them to the list of property paths.
                    var nestedTypePaths = this.GetAllNestedPropertyPaths(qcxt, operationFilter, navigationPropertyFilter);

                    foreach (var nestedTypePath in nestedTypePaths)
                    {
                        var propertyPath = new string[] { property.Name };
                        propertyPath = propertyPath.Concat(nestedTypePath).ToArray();

                        if (navigationPropertyFilter != NavigationPropertyFilter.NavigationOnly)
                        {
                            allPropertyPaths.Add(propertyPath);
                        }
                    }
                }
                else if (qct != null)
                {
                    if (navigationPropertyFilter != NavigationPropertyFilter.NonNavigationOnly)
                    {
                        allPropertyPaths.Add(new string[] { property.Name });
                    }
                }
            }

            return(allPropertyPaths.AsEnumerable());
        }