public static RelationshipReferenceMapping GetMapping()
        {
            RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl();
            mapping.FromRelationship = new RelationshipImpl(new Guid("21111111-1111-1111-1111-111111111111"));
            mapping.ToReference = new ReferenceImpl(new Guid("11111111-1111-1111-1111-111111111111"));

            return mapping;
        }
예제 #2
0
        public static void ProcessRelationshipInternal(MappingSet set, Relationship relationship, EntityProcessor processor)
        {
            Reference reference = processor.CreateReference(relationship, set.EntitySet);

            if (reference == null)
                return;

            RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl();
            mapping.FromRelationship = relationship;
            mapping.ToReference = reference;
            //set.EntitySet.AddReference(reference);
            set.AddMapping(mapping);
        }
예제 #3
0
        public void To(Relationship relationship)
        {
            RemoveOldMapping();

            if (relationship == null)
            {
                return;
            }

            RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl()
            {
                FromRelationship = relationship, ToReference = reference
            };

            ms.AddMapping(mapping);
            ms.InvalidateCache();
        }
        public RelationshipReferenceMapping DeserialiseRelationshipMapping(XmlNode relationshipMappingNode, IDatabase database, EntitySet set)
        {
            NodeProcessor proc = new NodeProcessor(relationshipMappingNode);
            RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl();

            Guid fromRelationshipId = proc.GetGuid("FromRelationship");
            Guid toReferenceId      = proc.GetGuid("ToReference");

            mapping.FromRelationship = database.Relationships.FirstOrDefault(r => r.Identifier == fromRelationshipId);
            mapping.ToReference      = set.References.FirstOrDefault(r => r.Identifier == toReferenceId);

            if (mapping.ToReference == null)
            {
                return(null);
            }

            ProcessScriptBase(mapping, relationshipMappingNode);

            return(mapping);
        }
예제 #5
0
        public void To(Relationship relationship)
        {
            RemoveOldMapping();

            if (relationship == null) return;

            RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl() { FromRelationship = relationship, ToReference = reference };
            ms.AddMapping(mapping);
            ms.InvalidateCache();
        }
        public RelationshipReferenceMapping DeserialiseRelationshipMapping(XmlNode relationshipMappingNode, IDatabase database, EntitySet set)
        {
            NodeProcessor proc = new NodeProcessor(relationshipMappingNode);
            RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl();

            Guid fromRelationshipId = proc.GetGuid("FromRelationship");
            Guid toReferenceId = proc.GetGuid("ToReference");

            mapping.FromRelationship = database.Relationships.FirstOrDefault(r => r.Identifier == fromRelationshipId);
            mapping.ToReference = set.References.FirstOrDefault(r => r.Identifier == toReferenceId);

            if (mapping.ToReference == null)
                return null;

            ProcessScriptBase(mapping, relationshipMappingNode);

            return mapping;
        }
        public void Setup()
        {
            mappingSet = new MappingSetImpl(new Database("DB1"), new EntitySetImpl());

            entity1 = new EntityImpl("Entity1");
            entity2 = new EntityImpl("Entity2");
            mappingSet.EntitySet.AddEntity(entity1);
            mappingSet.EntitySet.AddEntity(entity2);

            reference1 = entity1.CreateReferenceTo(entity2);
            var reference2 = entity1.CreateReferenceTo(entity2);

            refMapping1 = new TableReferenceMappingImpl { FromTable = new Table("Table2"), ToReference = reference2 };
            var refMapping2 = new TableReferenceMappingImpl { FromTable = new Table("Table1"), ToReference = reference1 };

            relMapping1 = new RelationshipReferenceMappingImpl { FromRelationship = new RelationshipImpl(), ToReference = reference2 };
            var relMapping2 = new RelationshipReferenceMappingImpl { FromRelationship = new RelationshipImpl(), ToReference = reference1 };

            mappingSet.AddMapping(refMapping1);
            mappingSet.AddMapping(refMapping2);

            mappingSet.AddMapping(relMapping1);
            mappingSet.AddMapping(relMapping2);
        }
        public void Setup()
        {
            mappingSet = new MappingSetImpl(new Database("DB1"), new EntitySetImpl());

            relationship1 = new RelationshipImpl();
            relMapping1 = new RelationshipReferenceMappingImpl { FromRelationship = new RelationshipImpl(), ToReference = new ReferenceImpl() };
            var relMapping2 = new RelationshipReferenceMappingImpl { FromRelationship = relationship1, ToReference = new ReferenceImpl() };

            mappingSet.AddMapping(relMapping1);
            mappingSet.AddMapping(relMapping2);
        }
 public void A_ToEntity__It_Should_Throw_An_Exception()
 {
     var mapping = new RelationshipReferenceMappingImpl();
     mapping.FromRelationship = new RelationshipImpl();
     new MappingSetSerialisationScheme().SerialiseRelationshipMapping(mapping);
 }
 public void A_FromTable__It_Should_Throw_An_Exception()
 {
     var mapping = new RelationshipReferenceMappingImpl();
     mapping.ToReference = new ReferenceImpl();
     new MappingSetSerialisationScheme().SerialiseRelationshipMapping(mapping);
 }