Esempio n. 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);
        }
Esempio n. 2
0
        public static bool IsAutoExpand(IEdmProperty navigationProperty,
                                        IEdmProperty pathProperty, IEdmStructuredType pathStructuredType, IEdmModel edmModel,
                                        bool isSelectPresent = false, ModelBoundQuerySettings querySettings = null)
        {
            QueryableRestrictionsAnnotation annotation = EdmHelpers.GetPropertyRestrictions(navigationProperty, edmModel);

            if (annotation != null && annotation.Restrictions.AutoExpand)
            {
                return(!annotation.Restrictions.DisableAutoExpandWhenSelectIsPresent || !isSelectPresent);
            }

            if (querySettings == null)
            {
                querySettings = edmModel.GetModelBoundQuerySettings(pathProperty, pathStructuredType);
            }

            if (querySettings != null && querySettings.IsAutomaticExpand(navigationProperty.Name))
            {
                return(true);
            }

            return(false);
        }