public override void Apply(PropertyConfiguration edmProperty,
                                   StructuralTypeConfiguration structuralTypeConfiguration,
                                   Attribute attribute,
                                   ODataConventionModelBuilder model)
        {
            if (edmProperty == null)
            {
                throw Error.ArgumentNull("edmProperty");
            }

            if (!edmProperty.AddedExplicitly)
            {
                ExpandAttribute         expandAttribute = attribute as ExpandAttribute;
                ModelBoundQuerySettings querySettings   = edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault();
                if (querySettings.ExpandConfigurations.Count == 0)
                {
                    querySettings.CopyExpandConfigurations(expandAttribute.ExpandConfigurations);
                }
                else
                {
                    foreach (var property in expandAttribute.ExpandConfigurations.Keys)
                    {
                        querySettings.ExpandConfigurations[property] =
                            expandAttribute.ExpandConfigurations[property];
                    }
                }

                if (expandAttribute.ExpandConfigurations.Count == 0)
                {
                    querySettings.DefaultExpandType = expandAttribute.DefaultExpandType;
                    querySettings.DefaultMaxDepth   = expandAttribute.DefaultMaxDepth ?? ODataValidationSettings.DefaultMaxExpansionDepth;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set the <see cref="ExpandAttribute"/>s of navigation properties of this structural type.
        /// </summary>
        /// <param name="edmTypeConfiguration">The entity 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)
            {
                ExpandAttribute expandAttribute = attribute as ExpandAttribute;

                /*
                 * ModelBoundQuerySettings querySettings =
                 *  edmTypeConfiguration.QueryConfiguration.GetModelBoundQuerySettingsOrDefault();
                 * if (querySettings.ExpandConfigurations.Count == 0)
                 * {
                 *  querySettings.CopyExpandConfigurations(
                 *      expandAttribute.ExpandConfigurations);
                 * }
                 * else
                 * {
                 *  foreach (var property in expandAttribute.ExpandConfigurations.Keys)
                 *  {
                 *      querySettings.ExpandConfigurations[property] =
                 *          expandAttribute.ExpandConfigurations[property];
                 *  }
                 * }
                 *
                 * if (expandAttribute.ExpandConfigurations.Count == 0)
                 * {
                 *  querySettings.DefaultExpandType = expandAttribute.DefaultExpandType;
                 *  querySettings.DefaultMaxDepth = expandAttribute.DefaultMaxDepth ?? ODataValidationSettings.DefaultMaxExpansionDepth;
                 * }
                 */
            }
        }