예제 #1
0
        public static HbmMapping GetMapings(ObjectRelationalMapper orm)
        {

            domainEntities =
                typeof(Entity).Assembly.GetTypes()
                    .Where(t => typeof(Entity).IsAssignableFrom(t) && !t.IsGenericType)
                    .ToList();
            orm.Cascade<Claim, CPS.Domain.Action>(CascadeOn.None);
            orm.Cascade<Branch, Claim>(CascadeOn.None);
            orm.Cascade<Domain.Action,Document>(CascadeOn.All);

            orm.Component<Address>();
            orm.Component<Incident>();
            orm.Component<ContactInfo>();

            var patterns = new SafePropertyAccessorPack().Merge(new OneToOneRelationPack(orm))
                .Merge(new BidirectionalManyToManyRelationPack(orm))
                .Merge(new BidirectionalOneToManyRelationPack(orm))
                .Merge(new DiscriminatorValueAsClassNamePack(orm))
                .Merge(new CoolColumnsNamingPack(orm))
                .Merge(new TablePerClassPack())
                .Merge(new ListIndexAsPropertyPosColumnNameApplier())
                .Merge(new PluralizedTablesPack(orm, new EnglishInflector()))
                .Merge(new MsSQL2008DateTimeApplier());


            var mapper = new Mapper(orm, patterns);

            var mapping = mapper.CompileMappingFor(domainEntities);
            Debug.WriteLine(mapping.AsString());
            return mapping;
        }
 public void RegisteringComponentAndEntityThrow()
 {
     var mapper = new ObjectRelationalMapper();
     mapper.Component<AComponent>();
     ActionAssert.Throws(() => mapper.TablePerClass<AComponent>()).Should().Be.InstanceOf<MappingException>();
     ActionAssert.Throws(() => mapper.TablePerConcreteClass<AComponent>()).Should().Be.InstanceOf<MappingException>();
     ActionAssert.Throws(() => mapper.TablePerClassHierarchy<AComponent>()).Should().Be.InstanceOf<MappingException>();
 }
        public void CanDiscoverManyToOneFromComponentToEntity()
        {
            var orm = new ObjectRelationalMapper();
            orm.TablePerClass<AEntity>();
            orm.TablePerClass<BEntity>();
            orm.Component<AComponent>();

            orm.IsManyToOne(typeof(AComponent), typeof(BEntity)).Should().Be.True();
        }
 public void WhenComponentRegisteredIsRecognized()
 {
     var mapper = new ObjectRelationalMapper();
     mapper.Component<AComponent>();
     mapper.IsComponent(typeof(AComponent)).Should().Be.True();
 }