コード例 #1
0
        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);
        }
コード例 #2
0
        public void RemoveMapping(RelationshipReferenceMapping mapping)
        {
            if (relationshipMappings.Remove(mapping))
            {
                mapping.MappingSet = null;
            }

            CacheInvalid = true;
            RaisePropertyChanged("RelationshipMappings");
        }
コード例 #3
0
        public void AddMapping(RelationshipReferenceMapping mapping)
        {
            if (relationshipMappings.Contains(mapping))
            {
                return;
            }

            relationshipMappings.Add(mapping);
            mapping.MappingSet = this;
            CacheInvalid       = true;
            RaisePropertyChanged("RelationshipMappings");
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void SerialiseRelationshipMappingInternal(RelationshipReferenceMapping mapping, XmlWriter writer)
        {
            if (mapping.FromRelationship == null)
                //throw new ArgumentNullException("mapping", string.Format("mapping.FromRelationship cannot be null [{0}]", mapping.DisplayName));
                return;
            if (mapping.ToReference == null)
                //throw new ArgumentNullException("mapping", string.Format("mapping.ToReference cannot be null [{0}]", mapping.DisplayName));
                return;

            WriterHelper document = new WriterHelper(writer);

            using (document.Element("RelationshipReferenceMapping"))
            {
                writer.WriteElementString("FromRelationship", mapping.FromRelationship.Identifier.ToString());
                writer.WriteElementString("ToReference", mapping.ToReference.Identifier.ToString());

                ProcessScriptBase(mapping, writer);
            }
        }
コード例 #6
0
        public void SerialiseRelationshipMappingInternal(RelationshipReferenceMapping mapping, XmlWriter writer)
        {
            if (mapping.FromRelationship == null)
            {
                //throw new ArgumentNullException("mapping", string.Format("mapping.FromRelationship cannot be null [{0}]", mapping.DisplayName));
                return;
            }
            if (mapping.ToReference == null)
            {
                //throw new ArgumentNullException("mapping", string.Format("mapping.ToReference cannot be null [{0}]", mapping.DisplayName));
                return;
            }

            WriterHelper document = new WriterHelper(writer);

            using (document.Element("RelationshipReferenceMapping"))
            {
                writer.WriteElementString("FromRelationship", mapping.FromRelationship.Identifier.ToString());
                writer.WriteElementString("ToReference", mapping.ToReference.Identifier.ToString());

                ProcessScriptBase(mapping, writer);
            }
        }
 public static void TestMapping(RelationshipReferenceMapping mapping, Relationship table, Reference reference)
 {
     Assert.That(mapping.FromRelationship, Is.SameAs(table));
     Assert.That(mapping.ToReference, Is.SameAs(reference));
 }
コード例 #8
0
 public void SetUp()
 {
     mapping = new RelationshipReferenceMappingImpl();
 }
コード例 #9
0
 public void SetUp()
 {
     mappingSet = new MappingSetImpl();
     mapping = new RelationshipReferenceMappingImpl();
     mappingSet.AddMapping(mapping);
 }
コード例 #10
0
 public void SetUp()
 {
     mappingSet = new MappingSetImpl();
     mapping    = new RelationshipReferenceMappingImpl();
 }
コード例 #11
0
        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);
        }
コード例 #12
0
 public string SerialiseRelationshipMapping(RelationshipReferenceMapping mapping)
 {
     return(Serialise(writer => SerialiseRelationshipMappingInternal(mapping, writer)));
 }
コード例 #13
0
        public MappingSet DeserialiseMappingSet(XmlNode mappingSetNode, IDatabase database, EntitySet entitySet)
        {
            var mappingSet = new MappingSetImpl(database, entitySet);
            var nodes      = mappingSetNode.SelectNodes("Mappings/Mapping");

            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    var mapping = DeserialiseMapping(node, database, entitySet);

                    if (mapping != null)
                    {
                        mappingSet.AddMapping(mapping);
                    }
                }
            }
            var refNodes = mappingSetNode.SelectNodes("ReferenceMappings/TableReferenceMapping");

            if (refNodes != null)
            {
                foreach (XmlNode node in refNodes)
                {
                    mappingSet.AddMapping(DeserialiseReferenceMapping(node, database, entitySet));
                }
            }

            var relationshipNodes = mappingSetNode.SelectNodes("ReferenceMappings/RelationshipReferenceMapping");

            if (relationshipNodes != null)
            {
                foreach (XmlNode node in relationshipNodes)
                {
                    RelationshipReferenceMapping relRefMapping = DeserialiseRelationshipMapping(node, database, entitySet);

                    if (relRefMapping != null)
                    {
                        mappingSet.AddMapping(relRefMapping);
                    }
                }
            }
            var componentNodes = mappingSetNode.SelectNodes("ComponentMappings/ComponentMapping");

            if (componentNodes != null)
            {
                foreach (XmlNode node in componentNodes)
                {
                    mappingSet.AddMapping(DeserialiseComponentMapping(node, database, entitySet));
                }
            }

            #region Table Prefixes
            var prefixNodes = mappingSetNode.SelectNodes("TablePrefixes/Prefix");

            if (prefixNodes != null)
            {
                foreach (XmlNode node in prefixNodes)
                {
                    mappingSet.TablePrefixes.Add(DeserialisePrefix(node));
                }
            }

            #endregion

            #region Column Prefixes
            prefixNodes = mappingSetNode.SelectNodes("ColumnPrefixes/Prefix");

            if (prefixNodes != null)
            {
                foreach (XmlNode node in prefixNodes)
                {
                    mappingSet.ColumnPrefixes.Add(DeserialisePrefix(node));
                }
            }

            #endregion

            #region Table Suffixes
            prefixNodes = mappingSetNode.SelectNodes("TableSuffixes/Suffix");

            if (prefixNodes != null)
            {
                foreach (XmlNode node in prefixNodes)
                {
                    mappingSet.TableSuffixes.Add(DeserialisePrefix(node));
                }
            }

            #endregion

            #region Column Prefixes
            prefixNodes = mappingSetNode.SelectNodes("ColumnSuffixes/Suffix");

            if (prefixNodes != null)
            {
                foreach (XmlNode node in prefixNodes)
                {
                    mappingSet.ColumnSuffixes.Add(DeserialisePrefix(node));
                }
            }

            #endregion

            ProcessScriptBase(mappingSet, mappingSetNode);
            return(mappingSet);
        }
コード例 #14
0
ファイル: MappingSet.cs プロジェクト: uQr/Visual-NHibernate
        public void RemoveMapping(RelationshipReferenceMapping mapping)
        {
            if (relationshipMappings.Remove(mapping))
            {
                mapping.MappingSet = null;
            }

            CacheInvalid = true;
            RaisePropertyChanged("RelationshipMappings");
        }
コード例 #15
0
ファイル: MappingSet.cs プロジェクト: uQr/Visual-NHibernate
        public void AddMapping(RelationshipReferenceMapping mapping)
        {
            if (relationshipMappings.Contains(mapping))
                return;

            relationshipMappings.Add(mapping);
            mapping.MappingSet = this;
            CacheInvalid = true;
            RaisePropertyChanged("RelationshipMappings");
        }
コード例 #16
0
 public string SerialiseRelationshipMapping(RelationshipReferenceMapping mapping)
 {
     return Serialise(writer => SerialiseRelationshipMappingInternal(mapping, writer));
 }
 public static void TestMapping(RelationshipReferenceMapping mapping, Relationship table, Reference reference)
 {
     Assert.That(mapping.FromRelationship, Is.SameAs(table));
     Assert.That(mapping.ToReference, Is.SameAs(reference));
 }
コード例 #18
0
        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);
        }