Example #1
0
        private FieldInfo GetFieldToSet(IConventionPropertyBase propertyBase)
        {
            if (propertyBase == null ||
                !ConfigurationSource.Convention.Overrides(propertyBase.GetFieldInfoConfigurationSource()) ||
                propertyBase.IsIndexerProperty() ||
                propertyBase.IsShadowProperty())
            {
                return(null);
            }

            var entityType = (IConventionEntityType)propertyBase.DeclaringType;
            var type       = entityType.ClrType;
            var baseTypes  = entityType.GetAllBaseTypes().ToArray();

            while (type != null)
            {
                var fieldInfo = TryMatchFieldName(propertyBase, entityType, type);
                if (fieldInfo != null &&
                    (propertyBase.PropertyInfo != null || propertyBase.Name == fieldInfo.GetSimpleMemberName()))
                {
                    return(fieldInfo);
                }

                type       = type.BaseType;
                entityType = baseTypes.FirstOrDefault(et => et.ClrType == type);
            }

            return(null);
        }
Example #2
0
        private FieldInfo GetFieldToSet(IConventionPropertyBase propertyBase)
        {
            if (propertyBase == null ||
                !ConfigurationSource.Convention.Overrides(propertyBase.GetFieldInfoConfigurationSource()) ||
                propertyBase.IsIndexerProperty())
            {
                return(null);
            }

            var type = propertyBase.DeclaringType.ClrType;

            while (type != null)
            {
                var fieldInfo = TryMatchFieldName(propertyBase, type);
                if (fieldInfo != null &&
                    (propertyBase.PropertyInfo != null || propertyBase.Name == fieldInfo.GetSimpleMemberName()))
                {
                    return(fieldInfo);
                }

                type = type.BaseType;
            }

            return(null);
        }