コード例 #1
0
 private void BuildFromFieldAttribute(PropertyInfo propertyInfo, PropertyMapping propertyMapping,
                                      FieldMetadataAttribute fieldAttribute)
 {
     propertyMapping.PropertyName  = propertyInfo.Name;
     propertyMapping.DatabaseType  = fieldAttribute.DbType;
     propertyMapping.ParameterName = fieldAttribute.ParameterName;
     propertyMapping.IsIdentity    = fieldAttribute.IsIdentity;
     propertyMapping.AllowDbNull   = fieldAttribute.AllowDbNull;
     propertyMapping.IsPrimaryKey  = fieldAttribute.IsPrimaryKey;
     propertyMapping.Order         = fieldAttribute.Order ?? 0;
     propertyMapping.IsPrimitive   = propertyInfo.PropertyType.IsPrimitive;
     propertyMapping.Field         = fieldAttribute.FieldName;
 }
コード例 #2
0
        private PropertyMapping BuildMappingFromProperty(PropertyInfo propertyInfo, int order)
        {
            if (propertyInfo.GetCustomAttribute <IgnoreAttribute>() != null)
            {
                return(null);
            }

            var propertyMapping = new PropertyMapping
            {
                PropertyName  = propertyInfo.Name,
                DatabaseType  = _dataBuilderHelper.InferDatabaseType(propertyInfo.PropertyType),
                ParameterName = _dataBuilderHelper.GetParameterName(propertyInfo.Name),
                IsIdentity    = false,
                AllowDbNull   = true,
                IsPrimaryKey  = false,
                Order         = order,
                IsPrimitive   = propertyInfo.PropertyType.IsPrimitive,
                Field         = propertyInfo.Name
            };

            return(propertyMapping);
        }
コード例 #3
0
        private void BuildPropertyMapping(PropertyInfo propertyInfo, TypeMapping typeMapping, int order)
        {
            var             fieldAttribute = propertyInfo.GetCustomAttribute <FieldMetadataAttribute>();
            var             joinAttribute  = propertyInfo.GetCustomAttribute <JoinAttribute>();
            var             countAttribute = propertyInfo.GetCustomAttribute <CountMetadataAttribute>();
            PropertyMapping propertyMapping;

            if (fieldAttribute == null)
            {
                propertyMapping = BuildMappingFromProperty(propertyInfo, order);
            }
            else
            {
                propertyMapping = new PropertyMapping();

                BuildFromFieldAttribute(propertyInfo, propertyMapping, fieldAttribute);
                BuildFromCountAttribute(typeMapping, countAttribute);
                BuildFromJoinAttribute(propertyMapping, joinAttribute);
            }

            AddPropertyMappingToTypeMapping(typeMapping, propertyMapping);
        }
コード例 #4
0
        private void BuildFromJoinAttribute(PropertyMapping propertyMapping, JoinAttribute joinAttribute)
        {
            if (joinAttribute == null)
            {
                return;
            }

            var joinMapping = new JoinMapping
            {
                JoinType          = joinAttribute.JoinType,
                LeftKey           = joinAttribute.LeftKey,
                RightKey          = joinAttribute.RightKey,
                JoinTable         = joinAttribute.JoinTable,
                JoinTableLeftKey  = joinAttribute.JoinTableLeftKey,
                JoinTableRightKey = joinAttribute.JoinTableRightKey,
                JoinTableJoinType = joinAttribute.JoinTableJoinType,
                ParentProperty    = joinAttribute.ParentProperty,
                ChildProperty     = joinAttribute.ChildProperty
            };

            propertyMapping.JoinMapping = joinMapping;
        }