示例#1
0
        private void LiftInheritedProperties(Type type, EntityType entityType)
        {
            EntityTypeConfiguration typeConfiguration = this._mappingContext.ModelConfiguration.GetStructuralTypeConfiguration(type) as EntityTypeConfiguration;

            if (typeConfiguration != null)
            {
                typeConfiguration.ClearKey();
                foreach (PropertyInfo instanceProperty in type.BaseType().GetInstanceProperties())
                {
                    PropertyInfo property = instanceProperty;
                    if (!this._mappingContext.AttributeProvider.GetAttributes(property).OfType <NotMappedAttribute>().Any <NotMappedAttribute>() && typeConfiguration.IgnoredProperties.Any <PropertyInfo>((Func <PropertyInfo, bool>)(p => p.IsSameAs(property))))
                    {
                        throw Error.CannotIgnoreMappedBaseProperty((object)property.Name, (object)type, (object)property.DeclaringType);
                    }
                }
            }
            List <EdmMember>       list            = entityType.DeclaredMembers.ToList <EdmMember>();
            HashSet <PropertyInfo> propertyInfoSet = new HashSet <PropertyInfo>(new PropertyFilter(this._mappingContext.ModelBuilderVersion).GetProperties(type, true, this._mappingContext.ModelConfiguration.GetConfiguredProperties(type), this._mappingContext.ModelConfiguration.StructuralTypes, false));

            foreach (EdmMember edmMember in list)
            {
                PropertyInfo clrPropertyInfo = edmMember.GetClrPropertyInfo();
                if (!propertyInfoSet.Contains(clrPropertyInfo))
                {
                    NavigationProperty navigationProperty = edmMember as NavigationProperty;
                    if (navigationProperty != null)
                    {
                        this._mappingContext.Model.RemoveAssociationType(navigationProperty.Association);
                    }
                    entityType.RemoveMember(edmMember);
                }
            }
        }