CompositeElementMapping ICompositeElementMappingProvider.GetCompositeElementMapping()
        {
            var mapping = new CompositeElementMapping(attributes.Clone());

            PopulateMapping(mapping);

            return(mapping);
        }
Exemplo n.º 2
0
        ManyToOneMapping IManyToOneMappingProvider.GetManyToOneMapping()
        {
            var mapping = new ManyToOneMapping(attributes.Clone())
            {
                ContainingEntityType = entity,
                Member = member
            };

            mapping.Set(x => x.Name, Layer.Defaults, member.Name);
            mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(TOther)));

            if (columns.Count == 0 && !mapping.IsSpecified("Formula"))
            {
                mapping.AddColumn(Layer.Defaults, CreateColumn(member.Name + "_id"));
            }

            foreach (var column in columns)
            {
                var columnMapping = CreateColumn(column);

                mapping.AddColumn(Layer.UserSupplied, columnMapping);
            }

            return(mapping);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        ColumnMapping CreateColumn(string column)
        {
            var columnMapping = new ColumnMapping(columnAttributes.Clone());

            columnMapping.Set(x => x.Name, Layer.Defaults, column);
            return(columnMapping);
        }
Exemplo n.º 5
0
        CacheMapping ICacheMappingProvider.GetCacheMapping()
        {
            var mapping = new CacheMapping(attributes.Clone());

            mapping.ContainedEntityType = entityType;

            return(mapping);
        }
Exemplo n.º 6
0
        SubclassMapping IIndeterminateSubclassMappingProvider.GetSubclassMapping(SubclassType type)
        {
            var mapping = new SubclassMapping(type);

            GenerateNestedSubclasses(mapping);

            attributes.Set("Type", Layer.Defaults, typeof(T));
            attributes.Set("Name", Layer.Defaults, typeof(T).AssemblyQualifiedName);
            attributes.Set("DiscriminatorValue", Layer.Defaults, typeof(T).Name);

            // TODO: un-hardcode this
            var key = new KeyMapping();

            key.AddColumn(Layer.Defaults, new ColumnMapping(typeof(T).BaseType.Name + "_id"));

            attributes.Set("TableName", Layer.Defaults, GetDefaultTableName());
            attributes.Set("Key", Layer.Defaults, key);

            // TODO: this is nasty, we should find a better way
            mapping.OverrideAttributes(attributes.Clone());

            foreach (var join in joins)
            {
                mapping.AddJoin(join);
            }

            foreach (var property in providers.Properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in providers.Components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var oneToOne in providers.OneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in providers.Collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in providers.References)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in providers.Anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            return(mapping.DeepClone());
        }
Exemplo n.º 7
0
        NaturalIdMapping INaturalIdMappingProvider.GetNaturalIdMapping()
        {
            var mapping = new NaturalIdMapping(attributes.Clone());

            properties.Each(mapping.AddProperty);
            manyToOnes.Each(mapping.AddReference);

            return(mapping);
        }
Exemplo n.º 8
0
        OneToOneMapping IOneToOneMappingProvider.GetOneToOneMapping()
        {
            var mapping = new OneToOneMapping(attributes.Clone());

            mapping.ContainingEntityType = entity;
            mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(TOther)));
            mapping.Set(x => x.Name, Layer.Defaults, member.Name);

            return(mapping);
        }
Exemplo n.º 9
0
        JoinMapping IJoinMappingProvider.GetJoinMapping()
        {
            var mapping = new JoinMapping(attributes.Clone())
            {
                ContainingEntityType = typeof(T)
            };

            if (columns.Count == 0)
            {
                var columnMapping = new ColumnMapping();
                columnMapping.Set(x => x.Name, Layer.Defaults, typeof(T).Name + "_id");
                mapping.Key.AddColumn(Layer.Defaults, columnMapping);
            }
            else
            {
                foreach (var column in columns)
                {
                    var columnMapping = new ColumnMapping();
                    columnMapping.Set(x => x.Name, Layer.Defaults, column);
                    mapping.Key.AddColumn(Layer.UserSupplied, columnMapping);
                }
            }

            foreach (var property in providers.Properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in providers.Components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var reference in providers.References)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in providers.Anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            foreach (var collection in providers.Collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var storedProcedure in providers.StoredProcedures)
            {
                mapping.AddStoredProcedure(storedProcedure.GetStoredProcedureMapping());
            }

            return(mapping);
        }
Exemplo n.º 10
0
        CompositeIdMapping ICompositeIdMappingProvider.GetCompositeIdMapping()
        {
            var mapping = new CompositeIdMapping(attributes.Clone())
            {
                ContainingEntityType = typeof(T)
            };

            keys.Each(mapping.AddKey);

            return(mapping);
        }
Exemplo n.º 11
0
        ElementMapping IElementMappingProvider.GetElementMapping()
        {
            var mapping = new ElementMapping(attributes.Clone());

            mapping.ContainingEntityType = entity;

            foreach (var column in Columns)
            {
                column.MergeAttributes(columnAttributes);
                mapping.AddColumn(Layer.Defaults, column);
            }

            return(mapping);
        }
Exemplo n.º 12
0
        IdMapping IIdentityMappingProvider.GetIdentityMapping()
        {
            var mapping = new IdMapping(attributes.Clone())
            {
                ContainingEntityType = entityType
            };

            if (columns.Count > 0)
            {
                foreach (var column in columns)
                {
                    var columnMapping = new ColumnMapping(columnAttributes.Clone());
                    columnMapping.Set(x => x.Name, Layer.Defaults, column);
                    mapping.AddColumn(Layer.UserSupplied, columnMapping);
                }
            }
            else if (HasNameSpecified)
            {
                var columnMapping = new ColumnMapping(columnAttributes.Clone());
                columnMapping.Set(x => x.Name, Layer.Defaults, name);
                mapping.AddColumn(Layer.Defaults, columnMapping);
            }

            if (member != null)
            {
                mapping.Set(x => x.Name, Layer.Defaults, name);
            }

            mapping.Set(x => x.Type, Layer.Defaults, new TypeReference(identityType));

            if (GeneratedBy.IsDirty)
            {
                mapping.Set(x => x.Generator, Layer.UserSupplied, GeneratedBy.GetGeneratorMapping());
            }

            return(mapping);
        }
Exemplo n.º 13
0
        AnyMapping IAnyMappingProvider.GetAnyMapping()
        {
            var mapping = new AnyMapping(attributes.Clone());

            if (typeColumns.Count() == 0)
            {
                throw new InvalidOperationException("<any> mapping is not valid without specifying an Entity Type Column");
            }
            if (identifierColumns.Count() == 0)
            {
                throw new InvalidOperationException("<any> mapping is not valid without specifying an Entity Identifier Column");
            }
            if (!idTypeSet)
            {
                throw new InvalidOperationException("<any> mapping is not valid without specifying an IdType");
            }

            mapping.ContainingEntityType = entity;

            mapping.Set(x => x.Name, Layer.Defaults, member.Name);

            if (!mapping.IsSpecified("MetaType"))
            {
                mapping.Set(x => x.MetaType, Layer.Defaults, new TypeReference(member.PropertyType));
            }

            if (metaValues.Count() > 0)
            {
                metaValues.Each(mapping.AddMetaValue);
                mapping.Set(x => x.MetaType, Layer.Defaults, new TypeReference(typeof(string)));
            }

            foreach (var column in typeColumns)
            {
                var columnMapping = new ColumnMapping();
                columnMapping.Set(x => x.Name, Layer.Defaults, column);
                mapping.AddTypeColumn(Layer.UserSupplied, columnMapping);
            }


            foreach (var column in identifierColumns)
            {
                var columnMapping = new ColumnMapping();
                columnMapping.Set(x => x.Name, Layer.Defaults, column);
                mapping.AddIdentifierColumn(Layer.UserSupplied, columnMapping);
            }

            return(mapping);
        }
Exemplo n.º 14
0
        VersionMapping IVersionMappingProvider.GetVersionMapping()
        {
            var mapping = new VersionMapping(attributes.Clone())
            {
                ContainingEntityType = entity
            };

            mapping.Set(x => x.Name, Layer.Defaults, member.Name);
            mapping.Set(x => x.Type, Layer.Defaults, member.PropertyType == typeof(DateTime) ? new TypeReference("timestamp") : new TypeReference(member.PropertyType));

            var defaultColumnMapping = new ColumnMapping(columnAttributes.Clone());

            defaultColumnMapping.Set(x => x.Name, Layer.Defaults, member.Name);
            mapping.AddColumn(Layer.Defaults, defaultColumnMapping);

            columns.ForEach(column =>
            {
                var columnMapping = new ColumnMapping(columnAttributes.Clone());
                columnMapping.Set(x => x.Name, Layer.Defaults, column);
                mapping.AddColumn(Layer.UserSupplied, columnMapping);
            });

            return(mapping);
        }
Exemplo n.º 15
0
        public IndexMapping GetIndexMapping()
        {
            var mapping = new IndexMapping(attributes.Clone());

            mapping.ContainingEntityType = entity;

            columns.Each(name =>
            {
                var columnMapping = new ColumnMapping();
                columnMapping.Set(x => x.Name, Layer.Defaults, name);
                mapping.AddColumn(Layer.UserSupplied, columnMapping);
            });

            return(mapping);
        }
Exemplo n.º 16
0
        DiscriminatorMapping IDiscriminatorMappingProvider.GetDiscriminatorMapping()
        {
            var mapping = new DiscriminatorMapping(attributes.Clone())
            {
                ContainingEntityType = entity,
            };

            mapping.Set(x => x.Type, Layer.Defaults, discriminatorValueType);

            var columnMapping = new ColumnMapping(columnAttributes.Clone());

            columnMapping.Set(x => x.Name, Layer.Defaults, columnName);
            mapping.AddColumn(Layer.Defaults, columnMapping);

            return(mapping);
        }
Exemplo n.º 17
0
        SubclassMapping ISubclassMappingProvider.GetSubclassMapping()
        {
            var mapping = new SubclassMapping(SubclassType.JoinedSubclass, attributes.Clone());

            mapping.Set(x => x.Key, Layer.Defaults, new KeyMapping {
                ContainingEntityType = typeof(TSubclass)
            });
            mapping.Set(x => x.Name, Layer.Defaults, typeof(TSubclass).AssemblyQualifiedName);
            mapping.Set(x => x.Type, Layer.Defaults, typeof(TSubclass));

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

            foreach (var property in providers.Properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in providers.Components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var oneToOne in providers.OneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in providers.Collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in providers.References)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in providers.Anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            return(mapping);
        }
Exemplo n.º 18
0
        SubclassMapping ISubclassMappingProvider.GetSubclassMapping()
        {
            var mapping = new SubclassMapping(SubclassType.Subclass, attributes.Clone());

            if (discriminatorValue != null)
            {
                mapping.Set(x => x.DiscriminatorValue, Layer.Defaults, discriminatorValue);
            }

            mapping.Set(x => x.Type, Layer.Defaults, typeof(TSubclass));
            mapping.Set(x => x.Name, Layer.Defaults, typeof(TSubclass).AssemblyQualifiedName);

            foreach (var property in providers.Properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in providers.Components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var oneToOne in providers.OneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in providers.Collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in providers.References)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in providers.Anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            subclassMappings.Each(mapping.AddSubclass);

            return(mapping);
        }
Exemplo n.º 19
0
        protected virtual CollectionMapping GetCollectionMapping()
        {
            var mapping = collectionBuilder(collectionAttributes.Clone());

            mapping.ContainingEntityType = entity;
            mapping.Member = member;
            mapping.Set(x => x.Name, Layer.Defaults, GetDefaultName());
            mapping.Set(x => x.ChildType, Layer.Defaults, typeof(TChild));
            mapping.Set(x => x.Key, Layer.Defaults, keyMapping);
            mapping.Set(x => x.Relationship, Layer.Defaults, GetRelationship());
            mapping.Key.ContainingEntityType = entity;

            if (Cache.IsDirty)
            {
                mapping.Set(x => x.Cache, Layer.Defaults, ((ICacheMappingProvider)Cache).GetCacheMapping());
            }

            if (componentMapping != null)
            {
                mapping.Set(x => x.CompositeElement, Layer.Defaults, componentMapping.GetCompositeElementMapping());
                mapping.Set(x => x.Relationship, Layer.Defaults, null); // HACK: bad design
            }

            // HACK: Index only on list and map - shouldn't have to do this!
            if (mapping.Collection == Collection.Array || mapping.Collection == Collection.List || mapping.Collection == Collection.Map)
            {
                mapping.Set(x => x.Index, Layer.Defaults, indexMapping);
            }

            if (elementPart != null)
            {
                mapping.Set(x => x.Element, Layer.Defaults, ((IElementMappingProvider)elementPart).GetElementMapping());
                mapping.Set(x => x.Relationship, Layer.Defaults, null); // HACK: bad design
            }

            foreach (var filterPart in Filters)
            {
                mapping.AddFilter(filterPart.GetFilterMapping());
            }

            return(mapping);
        }
Exemplo n.º 20
0
        protected ComponentMapping CreateComponentMapping()
        {
            var mapping = CreateComponentMappingRoot(attributes.Clone());

            if (member != null)
            {
                mapping.Set(x => x.Name, Layer.Defaults, member.Name);
            }

            foreach (var property in providers.Properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in providers.Components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var oneToOne in providers.OneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in providers.Collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in providers.References)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in providers.Anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            return(mapping);
        }
 public void CreateNewAttributeStore()
 {
     var store = new AttributeStore();
     var value = new object();
     store.Set("name1", value, new NameValueMapAttribute { Name = "A.B.C" });
     store.Get("name1").Layer.ShouldEqual(3);
     store.Get("name1").Value.ShouldEqual(value);
     store.Set("name1", value, new NameValueMapAttribute { Name = "A.B" });
     store.Get("name1").Layer.ShouldEqual(2);
     store.Get("name1").Value.ShouldEqual(value);
     store.Equals(store.Clone()).ShouldBeTrue();
 }
Exemplo n.º 22
0
 protected override ComponentMapping CreateComponentMappingRoot(AttributeStore store)
 {
     return(new ExternalComponentMapping(ComponentType.Component, attributes.Clone()));
 }
Exemplo n.º 23
0
 HibernateMapping IHibernateMappingProvider.GetHibernateMapping()
 {
     return(new HibernateMapping(attributes.Clone()));
 }
Exemplo n.º 24
0
        ClassMapping IMappingProvider.GetClassMapping()
        {
            var mapping = new ClassMapping(attributes.Clone());

            mapping.Set(x => x.Type, Layer.Defaults, typeof(T));
            mapping.Set(x => x.Name, Layer.Defaults, typeof(T).AssemblyQualifiedName);

            foreach (var property in providers.Properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in providers.Components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            if (providers.Version != null)
            {
                mapping.Set(x => x.Version, Layer.Defaults, providers.Version.GetVersionMapping());
            }

            foreach (var oneToOne in providers.OneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in providers.Collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in providers.References)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in providers.Anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            foreach (var subclass in providers.Subclasses.Values)
            {
                mapping.AddSubclass(subclass.GetSubclassMapping());
            }

            foreach (var join in providers.Joins)
            {
                mapping.AddJoin(join.GetJoinMapping());
            }

            if (providers.Discriminator != null)
            {
                mapping.Set(x => x.Discriminator, Layer.Defaults, providers.Discriminator.GetDiscriminatorMapping());
            }

            if (Cache.IsDirty)
            {
                mapping.Set(x => x.Cache, Layer.Defaults, ((ICacheMappingProvider)Cache).GetCacheMapping());
            }

            if (providers.Id != null)
            {
                mapping.Set(x => x.Id, Layer.Defaults, providers.Id.GetIdentityMapping());
            }

            if (providers.CompositeId != null)
            {
                mapping.Set(x => x.Id, Layer.Defaults, providers.CompositeId.GetCompositeIdMapping());
            }

            if (providers.NaturalId != null)
            {
                mapping.Set(x => x.NaturalId, Layer.Defaults, providers.NaturalId.GetNaturalIdMapping());
            }

            mapping.Set(x => x.TableName, Layer.Defaults, GetDefaultTableName());

            foreach (var filter in providers.Filters)
            {
                mapping.AddFilter(filter.GetFilterMapping());
            }

            foreach (var storedProcedure in providers.StoredProcedures)
            {
                mapping.AddStoredProcedure(storedProcedure.GetStoredProcedureMapping());
            }

            mapping.Set(x => x.Tuplizer, Layer.Defaults, providers.TuplizerMapping);

            return(mapping);
        }
Exemplo n.º 25
0
 internal ImportMapping GetImportMapping()
 {
     return(new ImportMapping(attributes.Clone()));
 }
Exemplo n.º 26
0
        SubclassMapping IIndeterminateSubclassMappingProvider.GetSubclassMapping(SubclassType type)
        {
            var mapping = new SubclassMapping(type);

            GenerateNestedSubclasses(mapping);

            attributes.Set("Type", Layer.Defaults, typeof(T));
            attributes.Set("Name", Layer.Defaults, typeof(T).AssemblyQualifiedName);
            attributes.Set("DiscriminatorValue", Layer.Defaults, typeof(T).Name);

            // TODO: un-hardcode this
            Type baseType = typeof(T).BaseType
                            ?? attributes.Get("Extends") as Type;

            if (baseType != null)
            {
                var key = new KeyMapping();
                key.AddColumn(Layer.Defaults, new ColumnMapping(baseType.Name + "_id"));
                attributes.Set("Key", Layer.Defaults, key);
            }

            attributes.Set("TableName", Layer.Defaults, GetDefaultTableName());

            // TODO: this is nasty, we should find a better way
            mapping.OverrideAttributes(attributes.Clone());

            foreach (var join in joins)
            {
                mapping.AddJoin(join);
            }

            foreach (var provider in providers.OrderedProviders)
            {
                var mappingProviderObj = provider.Item2;
                switch (provider.Item1)
                {
                case MappingProviderStore.ProviderType.Property:
                    mapping.AddProperty(((IPropertyMappingProvider)mappingProviderObj).GetPropertyMapping());
                    break;

                case MappingProviderStore.ProviderType.Component:
                    mapping.AddComponent(((IComponentMappingProvider)mappingProviderObj).GetComponentMapping());
                    break;

                case MappingProviderStore.ProviderType.OneToOne:
                    mapping.AddOneToOne(((IOneToOneMappingProvider)mappingProviderObj).GetOneToOneMapping());
                    break;

                case MappingProviderStore.ProviderType.Collection:
                    mapping.AddCollection(((ICollectionMappingProvider)mappingProviderObj).GetCollectionMapping());
                    break;

                case MappingProviderStore.ProviderType.ManyToOne:
                    mapping.AddReference(((IManyToOneMappingProvider)mappingProviderObj).GetManyToOneMapping());
                    break;

                case MappingProviderStore.ProviderType.Any:
                    mapping.AddAny(((IAnyMappingProvider)mappingProviderObj).GetAnyMapping());
                    break;

                case MappingProviderStore.ProviderType.Subclass:
                case MappingProviderStore.ProviderType.Filter:
                case MappingProviderStore.ProviderType.StoredProcedure:
                case MappingProviderStore.ProviderType.Join:
                case MappingProviderStore.ProviderType.Identity:
                case MappingProviderStore.ProviderType.CompositeId:
                case MappingProviderStore.ProviderType.NaturalId:
                case MappingProviderStore.ProviderType.Version:
                case MappingProviderStore.ProviderType.Discriminator:
                case MappingProviderStore.ProviderType.Tupilizer:
                default:
                    throw new Exception("Internal Error");
                }
            }

            return(mapping.DeepClone());
        }
Exemplo n.º 27
0
        ClassMapping IMappingProvider.GetClassMapping()
        {
            var mapping = new ClassMapping(attributes.Clone());

            mapping.Set(x => x.Type, Layer.Defaults, typeof(T));
            mapping.Set(x => x.Name, Layer.Defaults, typeof(T).AssemblyQualifiedName);

            if (providers.Version != null)
            {
                mapping.Set(x => x.Version, Layer.Defaults, providers.Version.GetVersionMapping());
            }

            foreach (var provider in providers.OrderedProviders)
            {
                var x = provider.Item2;
                switch (provider.Item1)
                {
                case MappingProviderStore.ProviderType.Property:
                    mapping.AddProperty(((IPropertyMappingProvider)x).GetPropertyMapping());
                    break;

                case MappingProviderStore.ProviderType.Component:
                    mapping.AddComponent(((IComponentMappingProvider)x).GetComponentMapping());
                    break;

                case MappingProviderStore.ProviderType.OneToOne:
                    mapping.AddOneToOne(((IOneToOneMappingProvider)x).GetOneToOneMapping());
                    break;

                case MappingProviderStore.ProviderType.Subclass:
                    mapping.AddSubclass(((ISubclassMappingProvider)x).GetSubclassMapping());
                    break;

                case MappingProviderStore.ProviderType.Collection:
                    mapping.AddCollection(((ICollectionMappingProvider)x).GetCollectionMapping());
                    break;

                case MappingProviderStore.ProviderType.ManyToOne:
                    mapping.AddReference(((IManyToOneMappingProvider)x).GetManyToOneMapping());
                    break;

                case MappingProviderStore.ProviderType.Any:
                    mapping.AddAny(((IAnyMappingProvider)x).GetAnyMapping());
                    break;

                case MappingProviderStore.ProviderType.Filter:
                    mapping.AddFilter(((IFilterMappingProvider)x).GetFilterMapping());
                    break;

                case MappingProviderStore.ProviderType.StoredProcedure:
                    mapping.AddStoredProcedure(((IStoredProcedureMappingProvider)x).GetStoredProcedureMapping());
                    break;

                case MappingProviderStore.ProviderType.Join:
                    mapping.AddJoin(((IJoinMappingProvider)x).GetJoinMapping());
                    break;

                case MappingProviderStore.ProviderType.Identity:
                    mapping.Set(y => y.Id, Layer.Defaults, ((IIdentityMappingProvider)x).GetIdentityMapping());
                    break;

                case MappingProviderStore.ProviderType.CompositeId:
                    mapping.Set(y => y.Id, Layer.Defaults, ((ICompositeIdMappingProvider)x).GetCompositeIdMapping());
                    break;

                case MappingProviderStore.ProviderType.NaturalId:
                    mapping.Set(y => y.NaturalId, Layer.Defaults, ((INaturalIdMappingProvider)x).GetNaturalIdMapping());
                    break;

                case MappingProviderStore.ProviderType.Version:
                    mapping.Set(y => y.Version, Layer.Defaults, ((IVersionMappingProvider)x).GetVersionMapping());
                    break;

                case MappingProviderStore.ProviderType.Discriminator:
                    mapping.Set(y => y.Discriminator, Layer.Defaults, ((IDiscriminatorMappingProvider)x).GetDiscriminatorMapping());
                    break;

                case MappingProviderStore.ProviderType.Tupilizer:
                    mapping.Set(y => y.Tuplizer, Layer.Defaults, (TuplizerMapping)x);
                    break;

                default:
                    throw new Exception("Internal Error");
                }
            }

            if (Cache.IsDirty)
            {
                mapping.Set(x => x.Cache, Layer.Defaults, ((ICacheMappingProvider)Cache).GetCacheMapping());
            }

            mapping.Set(x => x.TableName, Layer.Defaults, GetDefaultTableName());

            mapping.Set(x => x.Tuplizer, Layer.Defaults, providers.TuplizerMapping);

            return(mapping);
        }