private static void PropertyConvension(IModelInspector modelInspector,
                                               PropertyPath propertyPath,
                                               IPropertyMapper propertyMapper)
        {
            if (modelInspector.IsSet(propertyPath.LocalMember))
            {
                propertyMapper.Access(Accessor.Field);
            }

            var type = propertyPath.LocalMember.GetPropertyOrFieldType();

            if (!type.IsNullable())
            {
                propertyMapper.NotNullable(true);
            }

            var propertyName = propertyPath.LocalMember.Name;

            if (modelInspector.IsComponent(propertyPath.LocalMember.ReflectedType))
            {
                var entityName = propertyPath.LocalMember.ReflectedType.Name;

                propertyMapper.Column(IdentityBuilder.BuildColumnName(entityName,
                                                                      propertyName));
            }
            else
            {
                propertyMapper.Column(IdentityBuilder.BuildColumnName(propertyName));
            }
        }
예제 #2
0
        void ApplyPropertyConvention(IModelInspector mi, PropertyPath type, IPropertyMapper map)
        {
            if (type.PreviousPath != null)
            {
                if (mi.IsComponent(((PropertyInfo)type.PreviousPath.LocalMember).PropertyType))
                {
                    map.Column(type.PreviousPath.LocalMember.Name + type.LocalMember.Name);
                }
            }

            if (type.LocalMember.GetCustomAttributes(typeof(UniqueAttribute), false).Any())
            {
                map.Unique(true);
            }

            var propertyInfo = type.LocalMember as PropertyInfo;

            if (propertyInfo != null)
            {
                if (propertyInfo.PropertyType == typeof(byte[]))
                {
                    map.Length(Int32.MaxValue);
                }

                return;
            }

            var fieldInfo = type.LocalMember as FieldInfo;

            if (fieldInfo != null && fieldInfo.FieldType == typeof(byte[]))
            {
                map.Length(Int32.MaxValue);
            }
        }
예제 #3
0
        private void ComponentNamingConvention(IModelInspector modelInspector, PropertyPath member, IPropertyMapper map)
        {
            var property = member.LocalMember as PropertyInfo;

            if (modelInspector.IsComponent(property.DeclaringType))
            {
                map.Column(ComponentColumnNaming(member.PreviousPath.LocalMember, member.LocalMember));
            }
        }
예제 #4
0
        public static void ComponentNamingConvention(IModelInspector modelInspector, PropertyPath member, IPropertyMapper map)
        {
            var property = member.LocalMember as PropertyInfo;

            if (modelInspector.IsComponent(property.DeclaringType))
            {
                map.Column(member.PreviousPath.LocalMember.Name + member.LocalMember.Name);
            }
        }
예제 #5
0
        /// <summary>
        /// Indicates if a given property matches a one to one component relationship
        /// </summary>
        /// <param name="property">The property</param>
        /// <param name="modelInspector">An instance of the current model inspector</param>
        /// <returns>True if the property matches a one to one component relationship, false if not</returns>
        private bool MatchOneToOneComponent(PropertyPath property, IModelInspector modelInspector)
        {
            bool result = false;
            var  one    = modelInspector.IsOneToOne(property.LocalMember.DeclaringType);

            if (modelInspector.IsComponent(property.LocalMember.DeclaringType))
            {
                result = (property.PreviousPath != null) && !property.PreviousPath.LocalMember.GetPropertyOrFieldType().IsGenericCollection();
            }

            return(result);
        }
예제 #6
0
        private void ApplyPropertyConvention(IModelInspector mi, PropertyPath type, IPropertyMapper map)
        {
            if (type.PreviousPath != null)
            {
                if (mi.IsComponent(((PropertyInfo)type.PreviousPath.LocalMember).PropertyType))
                {
                    map.Column(type.PreviousPath.LocalMember.Name + type.LocalMember.Name);
                }
            }

            if (type.LocalMember.GetCustomAttributes(typeof(UniqueAttribute), false).Any())
            {
                map.Unique(true);
            }
        }
        void ApplyPropertyConvention(IModelInspector mi, PropertyPath type, IPropertyMapper map)
        {
            if (type.PreviousPath != null)
            {
                if (mi.IsComponent(((PropertyInfo)type.PreviousPath.LocalMember).PropertyType))
                {
                    map.Column(type.PreviousPath.LocalMember.Name + type.LocalMember.Name);
                }
            }

            if (type.LocalMember.DeclaringType != null)
            {
                var sagaMetadata = sagaMetaModel.FirstOrDefault(sm => sm.SagaEntityType == type.LocalMember.DeclaringType);

                if (sagaMetadata != null)
                {
                    SagaMetadata.CorrelationPropertyMetadata correlationProperty;
                    if (sagaMetadata.TryGetCorrelationProperty(out correlationProperty) && correlationProperty.Name == type.LocalMember.Name)
                    {
                        map.Unique(true);
                    }
                }
            }

            var propertyInfo = type.LocalMember as PropertyInfo;

            if (propertyInfo != null)
            {
                if (propertyInfo.PropertyType == typeof(byte[]))
                {
                    map.Length(int.MaxValue);
                }

                return;
            }

            var fieldInfo = type.LocalMember as FieldInfo;

            if (fieldInfo != null && fieldInfo.FieldType == typeof(byte[]))
            {
                map.Length(int.MaxValue);
            }
        }
예제 #8
0
        /// <summary>
        /// Indicates if a given property matches a one to one component relationship
        /// </summary>
        /// <param name="property">The property</param>
        /// <param name="modelInspector">An instance of the current model inspector</param>
        /// <returns>True if the property matches a one to one component relationship, false if not</returns>
        private bool MatchOneToOneComponent(PropertyPath property, IModelInspector modelInspector)
        {
            bool result = false;
            if (modelInspector.IsComponent(property.LocalMember.DeclaringType))
            {
                result = (property.PreviousPath != null) && !property.PreviousPath.LocalMember.GetPropertyOrFieldType().IsGenericCollection();
            }

            return result;
        }
예제 #9
0
 private void TryMapComponent(IModelInspector modelInspector, PropertyPath member, IPropertyMapper propertyCustomizer)
 {
     if (modelInspector.IsComponent(member.LocalMember.DeclaringType)
         && !modelInspector.IsPersistentId(member.PreviousPath.LocalMember))
     {
         propertyCustomizer.Column(member.PreviousPath.LocalMember.Name + "_" + member.LocalMember.Name);
     }
 }