Exemplo n.º 1
0
        public Relationship CreateRelationshipTo(ITable targetTable)
        {
            var newRel = new RelationshipImpl();

            newRel.PrimaryTable = this;
            newRel.ForeignTable = targetTable;

            newRel.PrimaryKey = new Key(Guid.NewGuid().ToString())
            {
                IsUserDefined = true, Keytype = DatabaseKeyType.Primary
            };
            newRel.ForeignKey = new Key(Guid.NewGuid().ToString())
            {
                IsUserDefined = true, Keytype = DatabaseKeyType.Foreign
            };

            AddKey(newRel.PrimaryKey);
            targetTable.AddKey(newRel.ForeignKey);

            newRel.PrimaryKey.Parent = this;
            newRel.ForeignKey.Parent = targetTable;

            newRel.Database = Database;
            Database.AddRelationship(newRel);

            AddRelationship(newRel);
            targetTable.AddRelationship(newRel);

            return(newRel);
        }
Exemplo n.º 2
0
 public void AddThisTo(ITable source, ITable target)
 {
     PrimaryTable = source;
     ForeignTable = target;
     Database     = source.Database;
     source.AddRelationship(this);
     target.AddRelationship(this);
     Database.AddRelationship(this);
 }
Exemplo n.º 3
0
        public void AddRelationship(Relationship relationship)
        {
            if (Relationships.Contains(relationship))
            {
                return;
            }
            _relationships.Add(relationship);
            relationship.Database = Database;

            Database.AddRelationship(relationship);
            RaisePropertyChanged("Relationships");
            RelationshipsChanged.RaiseAdditionEventEx(this, relationship);
        }
Exemplo n.º 4
0
        public Relationship CreateRelationshipUsing(IKey thisKey, IKey otherTableKey)
        {
            var newRel = new RelationshipImpl();

            newRel.PrimaryTable = this;
            newRel.ForeignTable = otherTableKey.Parent;

            newRel.PrimaryKey = thisKey;
            newRel.ForeignKey = otherTableKey;

            AddRelationship(newRel);
            otherTableKey.Parent.AddRelationship(newRel);

            newRel.Database = Database;
            Database.AddRelationship(newRel);

            return(newRel);
        }