Example #1
0
        private static bool CanExpand(this IEdmModel edmModel, IEdmStructuredType structuredType, IEdmProperty property)
        {
            // first for back-compability, check the queryable restriction
            QueryableRestrictionsAnnotation annotation = EdmHelpers.GetPropertyRestrictions(property, edmModel);

            if (annotation != null && annotation.Restrictions.NotExpandable)
            {
                return(false);
            }

            ModelBoundQuerySettings settings = edmModel.GetModelBoundQuerySettingsOrNull(structuredType, property);

            if (settings != null && !settings.Expandable(property.Name))
            {
                return(false);
            }

            return(true);
        }
Example #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);
        }