Ejemplo n.º 1
0
        public static bool IsNotSortable(IEdmProperty edmProperty, IEdmProperty pathEdmProperty,
                                         IEdmStructuredType pathEdmStructuredType, IEdmModel edmModel, bool enableOrderBy)
        {
            QueryableRestrictionsAnnotation annotation = GetPropertyRestrictions(edmProperty, edmModel);

            if (annotation != null && annotation.Restrictions.NotSortable)
            {
                return(true);
            }
            else
            {
                if (pathEdmStructuredType == null)
                {
                    pathEdmStructuredType = edmProperty.DeclaringType;
                }

                ModelBoundQuerySettings querySettings = GetModelBoundQuerySettings(pathEdmProperty,
                                                                                   pathEdmStructuredType, edmModel);
                if (!enableOrderBy)
                {
                    return(!querySettings.Sortable(edmProperty.Name));
                }

                bool enable;
                if (querySettings.OrderByConfigurations.TryGetValue(edmProperty.Name, out enable))
                {
                    return(!enable);
                }
                else
                {
                    return(querySettings.DefaultEnableOrderBy == false);
                }
            }
        }
Ejemplo n.º 2
0
        public static bool IsNotCountable(
            IEdmProperty property,
            IEdmStructuredType structuredType,
            IEdmModel edmModel,
            bool enableCount)
        {
            if (property != null)
            {
                QueryableRestrictionsAnnotation annotation = GetPropertyRestrictions(property, edmModel);
                if (annotation != null && annotation.Restrictions.NotCountable)
                {
                    return(true);
                }
            }

            ModelBoundQuerySettings querySettings = GetModelBoundQuerySettings(property, structuredType, edmModel);

            if (querySettings != null &&
                ((!querySettings.Countable.HasValue && !enableCount) || querySettings.Countable == false))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private static bool CanExpand(this IEdmModel edmModel, IEdmStructuredType structuredType, IEdmProperty property)
        {
            // first for back-compability, check the queryable restriction
            QueryableRestrictionsAnnotation annotation = EdmLibHelpers.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);
        }
Ejemplo n.º 4
0
        public static bool IsAutoExpand(IEdmProperty navigationProperty,
                                        IEdmProperty pathProperty, IEdmStructuredType pathStructuredType, IEdmModel edmModel,
                                        bool isSelectPresent = false, ModelBoundQuerySettings querySettings = null)
        {
            QueryableRestrictionsAnnotation annotation = GetPropertyRestrictions(navigationProperty, edmModel);

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

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

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

            return(false);
        }
Ejemplo n.º 5
0
        public static bool IsNotExpandable(IEdmProperty edmProperty, IEdmModel edmModel)
        {
            QueryableRestrictionsAnnotation annotation = GetPropertyRestrictions(edmProperty, edmModel);

            return(annotation == null ? false : annotation.Restrictions.NotExpandable);
        }