Exemplo n.º 1
0
        public override void Apply(NavigationPropertyConfiguration edmProperty,
                                   StructuralTypeConfiguration structuralTypeConfiguration,
                                   Attribute attribute,
                                   ODataConventionModelBuilder model)
        {
            if (edmProperty == null)
            {
                throw Error.ArgumentNull("edmProperty");
            }

            if (!edmProperty.AddedExplicitly)
            {
                AutoExpandAttribute autoExpandAttribute = attribute as AutoExpandAttribute;
                edmProperty.AutomaticallyExpand(autoExpandAttribute.DisableWhenSelectPresent);
            }
        }
        /// <summary>
        /// Set all navigation properties auto expand.
        /// </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");
            }

            EntityTypeConfiguration entityTypeConfiguration = edmTypeConfiguration as EntityTypeConfiguration;
            AutoExpandAttribute     autoExpandAttribute     = attribute as AutoExpandAttribute;

            foreach (var property in entityTypeConfiguration.NavigationProperties)
            {
                if (!property.AddedExplicitly)
                {
                    property.AutomaticallyExpand(autoExpandAttribute.DisableWhenSelectPresent);
                }
            }
        }