Esempio n. 1
0
        PropertyMapping IPropertyMappingProvider.GetPropertyMapping()
        {
            var mapping = new PropertyMapping(attributes.Clone())
            {
                ContainingEntityType = parentType,
                Member = member
            };

            if (columns.Count() == 0 && !mapping.IsSpecified("Formula"))
            {
                var columnMapping = new ColumnMapping(columnAttributes.Clone());
                columnMapping.Set(x => x.Name, Layer.Defaults, member.Name);
                mapping.AddColumn(Layer.Defaults, columnMapping);
            }

            foreach (var column in columns)
            {
                mapping.AddColumn(Layer.UserSupplied, column);
            }

            foreach (var column in mapping.Columns)
            {
                if (member.PropertyType.IsNullable() && member.PropertyType.IsEnum())
                {
                    column.Set(x => x.NotNull, Layer.Defaults, false);
                }

                column.MergeAttributes(columnAttributes);
            }

            mapping.Set(x => x.Name, Layer.Defaults, mapping.Member.Name);
            mapping.Set(x => x.Type, Layer.Defaults, GetDefaultType());

            return(mapping);
        }
Esempio n. 2
0
        PropertyMapping IPropertyMappingProvider.GetPropertyMapping()
        {
            var mapping = new PropertyMapping(attributes.CloneInner())
            {
                ContainingEntityType = parentType,
                Member = property
            };

            if (columns.Count() == 0 && !mapping.IsSpecified("Formula"))
            {
                mapping.AddDefaultColumn(new ColumnMapping(columnAttributes.CloneInner())
                {
                    Name = property.Name
                });
            }

            foreach (var column in columns)
            {
                mapping.AddColumn(column);
            }

            foreach (var column in mapping.Columns)
            {
                if (!column.IsSpecified("NotNull") && property.PropertyType.IsNullable() && property.PropertyType.IsEnum())
                {
                    column.SetDefaultValue(x => x.NotNull, false);
                }

                column.MergeAttributes(columnAttributes);
            }

            if (!mapping.IsSpecified("Name"))
            {
                mapping.Name = mapping.Member.Name;
            }

            if (!mapping.IsSpecified("Type"))
            {
                mapping.SetDefaultValue("Type", GetDefaultType());
            }

            return(mapping);
        }
Esempio n. 3
0
        protected override CollectionMapping GetCollectionMapping()
        {
            var collection = base.GetCollectionMapping();

            if (keyColumns.Count() == 0)
            {
                collection.Key.AddColumn(Layer.Defaults, new ColumnMapping(entity.Name + "_id"));
            }

            foreach (var column in keyColumns)
            {
                collection.Key.AddColumn(Layer.UserSupplied, column);
            }

            // HACK: shouldn't have to do this!
            if (manyToManyIndex != null && collection.Collection == Collection.Map)
#pragma warning disable 612,618
            {
                collection.Set(x => x.Index, Layer.Defaults, manyToManyIndex.GetIndexMapping());
            }
#pragma warning restore 612,618

            return(collection);
        }
        protected override ICollectionMapping GetCollectionMapping()
        {
            var collection = base.GetCollectionMapping();

            if (keyColumns.Count() == 0)
            {
                collection.Key.AddDefaultColumn(new ColumnMapping {
                    Name = entity.Name + "_id"
                });
            }

            foreach (var column in keyColumns)
            {
                collection.Key.AddColumn(column);
            }

            // HACK: shouldn't have to do this!
            if (manyToManyIndex != null && collection is MapMapping)
            {
                ((MapMapping)collection).Index = manyToManyIndex.GetIndexMapping();
            }

            return(collection);
        }