/// <summary>
        /// Removes the property from the edm type.
        /// </summary>
        /// <param name="edmProperty">The property being removed.</param>
        /// <param name="structuralTypeConfiguration">The edm type from which the property is being removed.</param>
        /// <param name="attribute">The <see cref="Attribute"/> found on this type.</param>
        public override void Apply(PropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute)
        {
            if (structuralTypeConfiguration == null)
            {
                throw Error.ArgumentNull("structuralTypeConfiguration");
            }

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

            bool isTypeDataContract   = structuralTypeConfiguration.ClrType.GetCustomAttributes(typeof(DataContractAttribute), inherit: true).Any();
            bool isPropertyDataMember = edmProperty.PropertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), inherit: true).Any();

            if (isTypeDataContract && isPropertyDataMember)
            {
                // both Datamember and IgnoreDataMember. DataMember wins as this a DataContract
                return;
            }
            else
            {
                structuralTypeConfiguration.RemoveProperty(edmProperty.PropertyInfo);
            }
        }
Example #2
0
        public override void Apply(PropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute)
        {
            if (edmProperty == null)
            {
                throw Error.ArgumentNull("edmProperty");
            }

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

            structuralTypeConfiguration.RemoveProperty(edmProperty.PropertyInfo);
        }
        public virtual void Ignore <TProperty>(Expression <Func <TStructuralType, TProperty> > propertyExpression)
        {
            PropertyInfo ignoredProperty = PropertySelectorVisitor.GetSelectedProperty(propertyExpression);

            _configuration.RemoveProperty(ignoredProperty);
        }