Defines the relationship between the ownming Business Object (IBusinessObject and the related Business Object. This class collaborates with the RelKeyDef, the ClassDef to provide a definition Relationship. This class along with the RelKeyDef and RelPropDef provides an implementation of the Foreign Key Mapping pattern (Fowler (236) - 'Patterns of Enterprise Application Architecture' - 'Maps an association between objects to a foreign Key Reference between tables.') The RelationshipDef should not be used by the Application developer since it is usually constructed based on the mapping in the ClassDef.xml file. The RelationshipDef (Relationship Definition) is used bay a ClassDef to define a particular relationship. Each relationship has a relationship name e.g. A relationship betwee a person and a department may manager, employee etc. The related Class e.g. A Department definition would contain a relationship definition to a Person Class. (to allow for the person class to be in a different assemply the assembly name is also stored. The list of properties the define the Foreign key mapping of relationship between these two classes is stored using the RelKeyDef. The Relationship also stores additional information such as DeleteParentAction and order critieria. The DeleteParentAction defines any constraints that the relationship should provide in the case of the parent (relationship owner e.g. Depertment in our example) being deleted. E.g. If the department (parent) is being deleted you may want to delete all related object or prevent delete if there are any related objects. In cases where there are many related objects e.g. A Department can have many Employees the relationship may be required to load in a specifically order e.g. by employee number. The order criteria is used for this.
Inheritance: IRelationshipDef
 /// <summary>
 /// Constructor for a new initialiser
 /// </summary>
 /// <param name="parentObject">The parent for the relationship</param>
 /// <param name="relationship">The relationship object</param>
 /// <param name="correspondingRelationshipName">The corresponding
 /// relationship name</param>
 public RelationshipObjectInitialiser(IBusinessObject parentObject, RelationshipDef relationship,
                                      string correspondingRelationshipName)
 {
     _parentObject = parentObject;
     _relationship = relationship;
     _correspondingRelationshipName = correspondingRelationshipName;
 }
Ejemplo n.º 2
0
 private static MockBO GetMockBO(out RelationshipDef mRelationshipDef, out RelKeyDef mRelKeyDef)
 {
     MockBO _mMockBO= new MockBO();
     IPropDefCol mPropDefCol = _mMockBO.PropDefCol;
     mRelKeyDef = new RelKeyDef();
     IPropDef propDef = mPropDefCol["MockBOProp1"];
     RelPropDef lRelPropDef = new RelPropDef(propDef, "MockBOID");
     mRelKeyDef.Add(lRelPropDef);
     mRelationshipDef = new SingleRelationshipDef("Relation1", typeof(MockBO), mRelKeyDef, false,
                                                  DeleteParentAction.Prevent);
     return _mMockBO;
 }
Ejemplo n.º 3
0
        public void init()
        {
            this.SetupDBConnection();

            mMockBo = new MockBO();
            mPropDefCol = mMockBo.PropDefCol;

            mRelKeyDef = new RelKeyDef();
            IPropDef propDef = mPropDefCol["MockBOProp1"];

            RelPropDef lRelPropDef = new RelPropDef(propDef, "MockBOID");
            mRelKeyDef.Add(lRelPropDef);

            mRelationshipDef = new SingleRelationshipDef
                ("Relation1", typeof (MockBO), mRelKeyDef, false, DeleteParentAction.Prevent);
            //DatabaseConnection.CurrentConnection.ConnectionString = MyDBConnection.GetConnectionString();
        }
        public void init()
        {
            BORegistry.DataAccessor = new DataAccessorInMemory();
            _fakeBO = new MockBO();
            _propDefCol = _fakeBO.PropDefCol;

            _RelKeyDef = new RelKeyDef();
            IPropDef propDef = _propDefCol["MockBOID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "MockBOProp1");
            _RelKeyDef.Add(relPropDef);

            _multipleRelationshipDef = new MultipleRelationshipDef("Relation1", typeof(MockBO),
                                                       _RelKeyDef, false, "",
                                                       DeleteParentAction.DeleteRelated);


            _singleRelationshipDef = new SingleRelationshipDef("Single", typeof(MockBO),
                                                       _RelKeyDef, false,
                                                       DeleteParentAction.DeleteRelated);
        }
        public void init()
        {
            _mockBo = new MockBO();
            _propDefCol = _mockBo.PropDefCol;

            _RelKeyDef = new RelKeyDef();
            IPropDef propDef = _propDefCol["MockBOID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "MockBOProp1");
            _RelKeyDef.Add(relPropDef);

            _multipleRelationshipDef = new MultipleRelationshipDef("Relation1", typeof(MockBO),
                                                       _RelKeyDef, false, "",
                                                       DeleteParentAction.DeleteRelated);


            _singleRelationshipDef = new SingleRelationshipDef("Single", typeof(MockBO),
                                                       _RelKeyDef, false,
                                                       DeleteParentAction.DeleteRelated);
            DatabaseConnection.CurrentConnection.ConnectionString = MyDBConnection.GetConnectionString();
        }
Ejemplo n.º 6
0
 public void CallRemove(RelationshipDef relDef)
 {
     Remove(relDef);
 }