Inheritance: MappingBase, ICollectionContentsMapping
        public void ShouldWriteManyToManyForManyToManyMapping()
        {
            var mapping = new ManyToManyMapping();

            writer.VerifyXml(mapping)
                .RootElement.HasName("many-to-many");
        }
        public void Should_generate_valid_hbm()
        {
            var manyToMany = new ManyToManyMapping {ClassName = "Class1"};
            var writer = new HbmManyToManyWriter();

            writer.ShouldGenerateValidOutput(manyToMany);
        }
 public override void ProcessManyToMany(ManyToManyMapping manyToManyMapping)
 {
     if (!manyToManyMapping.Attributes.IsSpecified(x => x.ClassName))
     {
         if (manyToManyMapping.ChildType == null)
             throw new ConventionException("Cannot apply the naming convention. No type specified.", manyToManyMapping);
         manyToManyMapping.ClassName = DetermineNameFromType(manyToManyMapping.ChildType);
     }
 }
        public void ShouldWriteColumns()
        {
            var container = new XmlWriterContainer();
            var mapping = new ManyToManyMapping();

            mapping.AddColumn(new ColumnMapping { Name = "Column1" });

            writer = container.Resolve<IXmlWriter<ManyToManyMapping>>();
            writer.VerifyXml(mapping)
                .Element("column").Exists();
        }
        public void Should_write_many_to_many()
        {
            var manyToMany = new ManyToManyMapping();
            var manyTomanyWriter = MockRepository.GenerateStub<IHbmWriter<ManyToManyMapping>>();
            manyTomanyWriter.Expect(x => x.Write(manyToMany)).Return(new HbmManyToMany());

            var writer = new HbmCollectionContentsWriter(null, manyTomanyWriter);

            object result = writer.Write(manyToMany);
            result.ShouldBeOfType(typeof(HbmManyToMany));
        }
        private ICollectionRelationshipMapping CreateManyToMany(PropertyInfo property, Type child, Type parent)
        {
            var mapping = new ManyToManyMapping
            {
                Class = new TypeReference(property.PropertyType.GetGenericArguments()[0]),
                ContainingEntityType = parent
            };

            mapping.AddDefaultColumn(new ColumnMapping { Name = child.Name + "_id" });

            return mapping;
        }
        static ICollectionRelationshipMapping CreateManyToMany(Member member, Type parentType, Type childType)
        {
            var columnMapping = new ColumnMapping();
            columnMapping.Set(x => x.Name, Layer.Defaults, childType.Name + "Id");

            var mapping = new ManyToManyMapping { ContainingEntityType = parentType };
            mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(childType));
            mapping.Set(x => x.ParentType, Layer.Defaults, parentType);
            mapping.Set(x => x.ChildType, Layer.Defaults, childType);
            mapping.AddColumn(Layer.Defaults, columnMapping);

            return mapping;
        }
        private static ICollectionRelationshipMapping CreateManyToMany(Member member, Type parentType, Type childType)
        {
            var ColumnMapping = new ColumnMapping();
            ColumnMapping.Set(x => x.Name, Layer.Defaults, "Id_" + childType.Name);

            var Mapping = new ManyToManyMapping {ContainingEntityType = parentType};
            Mapping.Set(x => x.Class, Layer.Defaults, new FluentNHibernate.MappingModel.TypeReference(childType));
            Mapping.Set(x => x.ParentType, Layer.Defaults, parentType);
            Mapping.Set(x => x.ChildType, Layer.Defaults, childType);
            Mapping.AddColumn(Layer.Defaults, ColumnMapping);

            return Mapping;
        }
 public bool Equals(ManyToManyMapping other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.attributes, attributes) &&
            other.columns.ContentEquals(columns) &&
            Equals(other.ContainingEntityType, ContainingEntityType));
 }
Esempio n. 10
0
        static ICollectionRelationshipMapping CreateManyToMany(Member property, Type child, Type parent)
        {
            var mapping = new ManyToManyMapping
            {
                ContainingEntityType = parent
            };
            mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(property.PropertyType.GetGenericArguments()[0]));

            var columnMapping = new ColumnMapping();
            columnMapping.Set(x => x.Name, Layer.Defaults, child.Name + "_id");
            mapping.AddColumn(Layer.Defaults, columnMapping);

            return mapping;
        }
 public ManyToManyInspector(ManyToManyMapping mapping)
 {
     this.mapping = mapping;
     mappedProperties.Map(x => x.LazyLoad, x => x.Lazy);
 }
 public void CreateDsl()
 {
     mapping = new ManyToManyMapping();
     inspector = new ManyToManyInspector(mapping);
 }
 public virtual void Visit(ManyToManyMapping mapping)
 {
 }
 public virtual void ProcessManyToMany(ManyToManyMapping manyToManyMapping)
 {
 }
        public void Should_apply_to_many_to_many_mapping()
        {
            var manyToManyMapping = new ManyToManyMapping();
            manyToManyMapping.ChildType = typeof (Album);
            _namingConvention.ProcessManyToMany(manyToManyMapping);

            manyToManyMapping.ClassName.ShouldEqual(manyToManyMapping.ChildType.AssemblyQualifiedName);
        }
 public ManyToManyInstance(ManyToManyMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
 }