Exemple #1
0
        void VisitExpand(ModelBoundQuerySettings querySettings, ICollection <string> properties)
        {
            var @default = new ExpandConfiguration();

            bool IsExpandAllowed(ExpandConfiguration expand)
            {
                if (expand.ExpandType == Disabled)
                {
                    return(false);
                }

                if (expand.MaxDepth != @default.MaxDepth)
                {
                    context.MaxExpansionDepth = expand.MaxDepth;
                }

                return(true);
            }

            Visit(querySettings, properties, Expand, IsExpandEnabled, context.AllowedExpandProperties, querySettings.ExpandConfigurations, IsExpandAllowed);
        }
Exemple #2
0
        public static bool IsExpandable(string propertyName, IEdmProperty property, IEdmStructuredType structuredType,
                                        IEdmModel edmModel,
                                        out ExpandConfiguration expandConfiguration)
        {
            expandConfiguration = null;
            ModelBoundQuerySettings querySettings = GetModelBoundQuerySettings(property, structuredType, edmModel);

            if (querySettings != null)
            {
                bool result = querySettings.Expandable(propertyName);
                if (!querySettings.ExpandConfigurations.TryGetValue(propertyName, out expandConfiguration) && result)
                {
                    expandConfiguration = new ExpandConfiguration
                    {
                        ExpandType = querySettings.DefaultExpandType.Value,
                        MaxDepth   = querySettings.DefaultMaxDepth
                    };
                }

                return(result);
            }

            return(false);
        }