Пример #1
0
        public override void establish_context()
        {
            manyToOneARankedFirstToHolder = new ManyToOneMapping();
            manyToOneARankedFirstToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder)));
            manyToOneARankedFirstToHolder.Set(x => x.Name, Layer.Defaults, "ARankedFirstProperty");
            manyToOneARankedFirstToHolder.ContainingEntityType = typeof(ARankedFirst);
            manyToOneARankedFirstToHolder.Member = new PropertyMember(typeof(ARankedFirst).GetProperty("ARankedFirstProperty"));

            manyToOneBRankedSecondToHolder = new ManyToOneMapping();
            manyToOneBRankedSecondToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder)));
            manyToOneBRankedSecondToHolder.Set(x => x.Name, Layer.Defaults, "BRankedSecondProperty");
            manyToOneBRankedSecondToHolder.ContainingEntityType = typeof(BRankedSecond);
            manyToOneBRankedSecondToHolder.Member = new PropertyMember(typeof(BRankedSecond).GetProperty("BRankedSecondProperty"));

            var relationship = new OneToManyMapping();

            relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(BRankedSecond)));
            relationship.ContainingEntityType = typeof(Holder);

            collectionMappingToBRankedSecond = CollectionMapping.Bag();
            collectionMappingToBRankedSecond.Set(x => x.ChildType, Layer.Defaults, typeof(BRankedSecond));
            collectionMappingToBRankedSecond.Set(x => x.Name, Layer.Defaults, "ColectionOfBRankedSeconds");
            collectionMappingToBRankedSecond.Set(x => x.Relationship, Layer.Defaults, relationship);
            collectionMappingToBRankedSecond.ContainingEntityType = typeof(Holder);

            visitor = new RelationshipPairingVisitor(A.Fake <PairBiDirectionalManyToManySidesDelegate>());
        }
        public override ExternalComponentMapping create_mapping()
        {
            var mapping = new ExternalComponentMapping(ComponentType.Component)
            {
                Access = "access",
                ContainingEntityType = typeof(Target),
                Insert         = true,
                Member         = new DummyPropertyInfo("name", typeof(Target)).ToMember(),
                Name           = "name",
                OptimisticLock = true,
                Parent         = new ParentMapping(),
                Type           = typeof(Target),
                Unique         = true,
                Update         = true
            };

            mapping.AddAny(new AnyMapping());
            mapping.AddCollection(CollectionMapping.Bag());
            mapping.AddComponent(new ComponentMapping(ComponentType.Component));
            mapping.AddFilter(new FilterMapping());
            mapping.AddJoin(new JoinMapping());
            mapping.AddOneToOne(new OneToOneMapping());
            mapping.AddProperty(new PropertyMapping());
            mapping.AddReference(new ManyToOneMapping());
            mapping.AddStoredProcedure(new StoredProcedureMapping());
            mapping.AddSubclass(new SubclassMapping(SubclassType.Subclass));

            return(mapping);
        }
        public override SubclassMapping create_mapping()
        {
            var mapping = new SubclassMapping(SubclassType.Subclass)
            {
                Abstract           = true,
                DynamicInsert      = true,
                DynamicUpdate      = true,
                EntityName         = "entity-name",
                Lazy               = true,
                Name               = "name",
                Proxy              = "proxy",
                SelectBeforeUpdate = true,
                Type               = typeof(Target),
                Extends            = typeof(Target),
                DiscriminatorValue = "value"
            };

            mapping.AddAny(new AnyMapping());
            mapping.AddCollection(CollectionMapping.Bag());
            mapping.AddComponent(new ComponentMapping(ComponentType.Component));
            mapping.AddFilter(new FilterMapping());
            mapping.AddJoin(new JoinMapping());
            mapping.AddOneToOne(new OneToOneMapping());
            mapping.AddProperty(new PropertyMapping());
            mapping.AddReference(new ManyToOneMapping());
            mapping.AddStoredProcedure(new StoredProcedureMapping());
            mapping.AddSubclass(new SubclassMapping(SubclassType.Subclass));

            return(mapping);
        }
        public override ClassMapping create_mapping()
        {
            var mapping = new ClassMapping
            {
                Abstract      = true, BatchSize = 10, Cache = new CacheMapping(),
                Check         = "check", Discriminator = new DiscriminatorMapping(), DiscriminatorValue = "value",
                DynamicInsert = true, DynamicUpdate = true, EntityName = "entity-name",
                Id            = new IdMapping(), Lazy = true, Mutable = true,
                Name          = "name", OptimisticLock = "lock", Persister = "persister",
                Polymorphism  = "poly", Proxy = "proxy", Schema = "schema",
                SchemaAction  = "action", SelectBeforeUpdate = true, Subselect = "subselect",
                TableName     = "table", Tuplizer = new TuplizerMapping(), Type = typeof(Target),
                Version       = new VersionMapping(), Where = "where"
            };

            mapping.AddAny(new AnyMapping());
            mapping.AddCollection(CollectionMapping.Bag());
            mapping.AddComponent(new ComponentMapping(ComponentType.Component));
            mapping.AddFilter(new FilterMapping());
            mapping.AddJoin(new JoinMapping());
            mapping.AddOneToOne(new OneToOneMapping());
            mapping.AddProperty(new PropertyMapping());
            mapping.AddReference(new ManyToOneMapping());
            mapping.AddStoredProcedure(new StoredProcedureMapping());
            mapping.AddSubclass(new SubclassMapping(SubclassType.Subclass));

            return(mapping);
        }
Пример #5
0
        public void ShouldWriteBagForBagMapping()
        {
            var mapping = CollectionMapping.Bag();

            writer.VerifyXml(mapping)
            .RootElement.HasName("bag");
        }
Пример #6
0
        public void ShouldNotWriteCollectionTypeWhenEmpty()
        {
            var mapping = CollectionMapping.Bag();

            mapping.Set(x => x.CollectionType, Layer.Defaults, TypeReference.Empty);
            writer.VerifyXml(mapping)
            .DoesntHaveAttribute("collection-type");
        }
Пример #7
0
        public void ShouldWriteBag()
        {
            var mapping = new SubclassMapping(SubclassType.JoinedSubclass);

            mapping.AddCollection(CollectionMapping.Bag());

            writer.VerifyXml(mapping)
            .Element("bag").Exists();
        }
        protected CollectionMapping collection_with_column(string column)
        {
            var collection = CollectionMapping.Bag();

            collection.Set(x => x.Key, Layer.Defaults, new KeyMapping());
            collection.Key.AddColumn(Layer.Defaults, new ColumnMapping(column));

            return(collection);
        }
        public void ShouldWriteBags()
        {
            var mapping = CreateInstance();

            mapping.AddCollection(CollectionMapping.Bag());

            writer.VerifyXml(mapping)
            .Element("bag").Exists();
        }
Пример #10
0
        public void ShouldWriteCollection()
        {
            var mapping = new JoinMapping();

            mapping.AddCollection(CollectionMapping.Bag());

            writer.VerifyXml(mapping)
            .Element("bag").Exists();
        }
Пример #11
0
        public void ShouldWriteElement()
        {
            var mapping = CollectionMapping.Bag();

            mapping.Set(x => x.Element, Layer.Defaults, new ElementMapping());

            writer.VerifyXml(mapping)
            .Element("element").Exists();
        }
Пример #12
0
        public void ShouldWriteCacheElement()
        {
            var mapping = CollectionMapping.Bag();

            mapping.Set(x => x.Cache, Layer.Defaults, new CacheMapping());

            writer.VerifyXml(mapping)
            .Element("cache").Exists();
        }
Пример #13
0
        public void ShouldWriteRelationshipElement()
        {
            var mapping = CollectionMapping.Bag();

            mapping.Set(x => x.Relationship, Layer.Defaults, new OneToManyMapping());

            writer.VerifyXml(mapping)
            .Element("one-to-many").Exists();
        }
Пример #14
0
        public void ShouldWriteKey()
        {
            var mapping = CollectionMapping.Bag();

            mapping.Set(x => x.Key, Layer.Defaults, new KeyMapping());

            writer.VerifyXml(mapping)
            .Element("key").Exists();
        }
Пример #15
0
        public void ShouldWriteBags()
        {
            var mapping = new ComponentMapping(ComponentType.DynamicComponent);

            mapping.AddCollection(CollectionMapping.Bag());

            writer.VerifyXml(mapping)
            .Element("bag").Exists();
        }
        protected static CollectionMapping collection <T>(Expression <Func <T, object> > expression)
        {
            var member = expression.ToMember();

            var bag = CollectionMapping.Bag();

            bag.ContainingEntityType = typeof(T);
            bag.Member = member;
            bag.Set(x => x.Relationship, Layer.Defaults, new ManyToManyMapping());
            bag.Set(x => x.ChildType, Layer.Defaults, member.PropertyType.GetGenericArguments()[0]);
            return(bag);
        }
        public override ReferenceComponentMapping create_mapping()
        {
            var mapping = new ReferenceComponentMapping(ComponentType.Component, new DummyPropertyInfo("name", typeof(Target)).ToMember(), typeof(Target), typeof(Target), null);

            mapping.AssociateExternalMapping(new ExternalComponentMapping(ComponentType.Component));
            mapping.Access = "access";
            mapping.ContainingEntityType = typeof(Target);
            mapping.Insert         = true;
            mapping.Name           = "name";
            mapping.OptimisticLock = true;
            mapping.Parent         = new ParentMapping();
            mapping.Unique         = true;
            mapping.Update         = true;
            mapping.AddAny(new AnyMapping());
            mapping.AddCollection(CollectionMapping.Bag());
            mapping.AddComponent(new ComponentMapping(ComponentType.Component));
            mapping.AddOneToOne(new OneToOneMapping());
            mapping.AddProperty(new PropertyMapping());
            mapping.AddReference(new ManyToOneMapping());

            return(mapping);
        }
Пример #18
0
        public override void establish_context()
        {
            parentMapping            = new ParentMapping();
            externalComponentMapping = new ExternalComponentMapping(ComponentType.Component);
            externalComponentMapping.Set(x => x.Access, Layer.Defaults, "access");
            externalComponentMapping.Set(x => x.Insert, Layer.Defaults, true);
            externalComponentMapping.Set(x => x.Lazy, Layer.Defaults, true);
            externalComponentMapping.Set(x => x.OptimisticLock, Layer.Defaults, true);
            externalComponentMapping.Set(x => x.Parent, Layer.Defaults, parentMapping);
            externalComponentMapping.Set(x => x.Unique, Layer.Defaults, true);
            externalComponentMapping.Set(x => x.Update, Layer.Defaults, true);
            externalComponentMapping.AddAny(new AnyMapping());
            externalComponentMapping.AddCollection(CollectionMapping.Bag());
            externalComponentMapping.AddComponent(new ComponentMapping(ComponentType.Component));
            externalComponentMapping.AddFilter(new FilterMapping());
            externalComponentMapping.AddOneToOne(new OneToOneMapping());
            externalComponentMapping.AddProperty(new PropertyMapping());
            externalComponentMapping.AddReference(new ManyToOneMapping());

            memberProperty            = new DummyPropertyInfo("Component", typeof(Target)).ToMember();
            referenceComponentMapping = new ReferenceComponentMapping(ComponentType.Component, memberProperty, typeof(ComponentTarget), typeof(Target), "column-prefix");
        }
        public override SubclassMapping create_mapping()
        {
            var mapping = new SubclassMapping(SubclassType.JoinedSubclass)
            {
                Abstract           = true,
                BatchSize          = 10,
                Check              = "check",
                DynamicInsert      = true,
                DynamicUpdate      = true,
                EntityName         = "entity-name",
                Lazy               = true,
                Name               = "name",
                Persister          = new TypeReference(typeof(Target)),
                Proxy              = "proxy",
                Schema             = "schema",
                SelectBeforeUpdate = true,
                Subselect          = "subselect",
                TableName          = "table",
                Type               = typeof(Target),
                Extends            = typeof(Target),
                Key = new KeyMapping()
            };

            mapping.AddAny(new AnyMapping());
            mapping.AddCollection(CollectionMapping.Bag());
            mapping.AddComponent(new ComponentMapping(ComponentType.Component));
            mapping.AddFilter(new FilterMapping());
            mapping.AddJoin(new JoinMapping());
            mapping.AddOneToOne(new OneToOneMapping());
            mapping.AddProperty(new PropertyMapping());
            mapping.AddReference(new ManyToOneMapping());
            mapping.AddStoredProcedure(new StoredProcedureMapping());
            mapping.AddSubclass(new SubclassMapping(SubclassType.Subclass));

            return(mapping);
        }
Пример #20
0
 /// <summary>
 /// Use a bag collection
 /// </summary>
 public T AsBag()
 {
     collectionBuilder = attrs => CollectionMapping.Bag(attrs);
     return((T)this);
 }