Пример #1
0
        public void WhenInterfaceIsImplementedByEntitiesThenRecognizeHeterogeneousAssociation()
        {
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <MyEntity>();
            orm.TablePerClass <MyRelation>();
            orm.TablePerClass <MyOtherEntity>();

            var        mapper  = new Mapper(orm);
            HbmMapping mapping = mapper.CompileMappingFor(new[] { typeof(MyEntity), typeof(MyRelation), typeof(MyDeepRelation), typeof(MyOtherEntity), typeof(MyOtherDeepRelation) });

            HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("MyEntity"));
            IEntityPropertyMapping propertyRelation = rc.Properties.Where(p => p.Name == "Relation").Single();

            propertyRelation.Should().Be.InstanceOf <HbmAny>();

            IEntityPropertyMapping propertyDeepRelation = rc.Properties.Where(p => p.Name == "DeepRelation").Single();

            propertyDeepRelation.Should().Be.InstanceOf <HbmAny>();
        }
Пример #2
0
        public void WhenInterfaceIsImplementedByEntitiesThenDoesNotRecognizeAsManyToOne()
        {
            // when there are more then one Hierarchy tree then it can't be directly interpreted as ManyToOne
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <MyEntity>();
            orm.TablePerClass <MyRelation>();
            orm.TablePerClass <MyOtherEntity>();

            var        mapper  = new Mapper(orm);
            HbmMapping mapping = mapper.CompileMappingFor(new[] { typeof(MyEntity), typeof(MyRelation), typeof(MyDeepRelation), typeof(MyOtherEntity), typeof(MyOtherDeepRelation) });

            HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("MyEntity"));
            IEntityPropertyMapping propertyRelation = rc.Properties.Where(p => p.Name == "Relation").Single();

            propertyRelation.Should().Not.Be.InstanceOf <HbmManyToOne>();

            IEntityPropertyMapping propertyDeepRelation = rc.Properties.Where(p => p.Name == "DeepRelation").Single();

            propertyDeepRelation.Should().Not.Be.InstanceOf <HbmManyToOne>();
        }