Ejemplo n.º 1
0
        /// <summary>
        /// Set whether the $count can be applied on the edm type.
        /// </summary>
        /// <param name="edmTypeConfiguration">The edm type to configure.</param>
        /// <param name="model">The edm model that this type belongs to.</param>
        /// <param name="attribute">The <see cref="Attribute"/> found on this type.</param>
        public override void Apply(StructuralTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model,
                                   Attribute attribute)
        {
            if (edmTypeConfiguration == null)
            {
                throw Error.ArgumentNull("edmTypeConfiguration");
            }

            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

            if (!edmTypeConfiguration.AddedExplicitly)
            {
                CountAttribute countAttribute = attribute as CountAttribute;

                /*
                 * if (countAttribute.Disabled)
                 * {
                 *  edmTypeConfiguration.QueryConfiguration.GetModelBoundQuerySettingsOrDefault().Countable = false;
                 * }
                 * else
                 * {
                 *  edmTypeConfiguration.QueryConfiguration.GetModelBoundQuerySettingsOrDefault().Countable = true;
                 * }
                 */
            }
        }
        public override void Apply(PropertyConfiguration edmProperty,
                                   StructuralTypeConfiguration structuralTypeConfiguration,
                                   Attribute attribute,
                                   ODataConventionModelBuilder model)
        {
            if (edmProperty == null)
            {
                throw Error.ArgumentNull("edmProperty");
            }

            if (!edmProperty.AddedExplicitly)
            {
                CountAttribute countAttribute = attribute as CountAttribute;
                if (countAttribute.Disabled)
                {
                    edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault().Countable = false;
                }
                else
                {
                    edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault().Countable = true;
                }
            }
        }