protected static RelationshipDefCol CreateRelationshipDefCol(PropDefCol lPropDefCol) { RelationshipDefCol relDefCol = new RelationshipDefCol(); //Define Driver Relationships RelKeyDef relKeyDef = new RelKeyDef(); IPropDef propDef = lPropDefCol[PK1_PROP1_NAME]; RelPropDef lRelPropDef = new RelPropDef(propDef, "DriverFK1"); relKeyDef.Add(lRelPropDef); propDef = lPropDefCol[PK1_PROP2_NAME]; lRelPropDef = new RelPropDef(propDef, "DriverFK2"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef = new MultipleRelationshipDef("Driver", typeof(Car), relKeyDef, true, "", DeleteParentAction.DereferenceRelated); relDefCol.Add(relDef); return(relDefCol); }
public void TestProtectedSets() { FakeRelationshipDef relDef = new FakeRelationshipDef(); RelKeyDef relKeyDef = new RelKeyDef(); PropDef propDef = new PropDef("prop", typeof(string), PropReadWriteRule.ReadWrite, null); relKeyDef.Add(new RelPropDef(propDef, "")); Assert.AreEqual("rel", relDef.RelationshipName); relDef.SetRelationshipName("newrel"); Assert.AreEqual("newrel", relDef.RelationshipName); Assert.AreEqual(typeof(MyRelatedBo), relDef.RelatedObjectClassType); relDef.SetRelatedObjectClassType(typeof(MyBO)); Assert.AreEqual(typeof(MyBO), relDef.RelatedObjectClassType); Assert.AreEqual("Habanero.Test", relDef.RelatedObjectAssemblyName); relDef.SetRelatedObjectAssemblyName("someassembly"); Assert.AreEqual("someassembly", relDef.RelatedObjectAssemblyName); Assert.AreEqual("Habanero.Test.MyBO", relDef.RelatedObjectClassName); relDef.SetRelatedObjectClassName("someclass"); Assert.AreEqual("someclass", relDef.RelatedObjectClassName); Assert.AreEqual(0, relDef.RelKeyDef.Count); relDef.SetRelKeyDef(relKeyDef); Assert.AreEqual(1, relDef.RelKeyDef.Count); Assert.IsTrue(relDef.KeepReferenceToRelatedObject); relDef.SetKeepReferenceToRelatedObject(false); Assert.IsFalse(relDef.KeepReferenceToRelatedObject); }
public void Test_CreateMultipleRelationshipDef_Association() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); ClassDef.ClassDefs.Clear(); OrganisationTestBO.LoadDefaultClassDef(); ContactPersonTestBO.LoadDefaultClassDef(); RelPropDef relPropDef = new RelPropDef(ClassDef.Get <OrganisationTestBO>().PropDefcol["OrganisationID"], "OrganisationID"); RelKeyDef relKeyDef = new RelKeyDef(); relKeyDef.Add(relPropDef); const int expectedTimeout = 550; MultipleRelationshipDef relationshipDef = new MultipleRelationshipDef("ContactPeople", "Habanero.Test.BO", "ContactPersonTestBO", relKeyDef, true, "", DeleteParentAction.DeleteRelated, InsertParentAction.InsertRelationship, RelationshipType.Association, expectedTimeout); OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); //---------------Assert Precondition---------------- Assert.AreEqual(expectedTimeout, relationshipDef.TimeOut); //---------------Execute Test ---------------------- MultipleRelationship <ContactPersonTestBO> relationship = (MultipleRelationship <ContactPersonTestBO>)relationshipDef.CreateRelationship(organisation, organisation.Props); //---------------Test Result ----------------------- Assert.AreEqual(expectedTimeout, relationship.TimeOut); Assert.AreEqual(InsertParentAction.InsertRelationship, relationship.RelationshipDef.InsertParentAction); }
public static IClassDef LoadDefaultClassDef_PreventAddChild() { XmlClassLoader itsLoader = CreateXmlClassLoader(); IClassDef itsClassDef = itsLoader.LoadClass( @" <class name=""OrganisationTestBO"" assembly=""Habanero.Test.BO"" table=""organisation""> <property name=""OrganisationID"" type=""Guid"" /> <property name=""Name"" /> <primaryKey> <prop name=""OrganisationID"" /> </primaryKey> </class> " ); RelPropDef relPropDef = new RelPropDef(itsClassDef.PropDefcol["OrganisationID"], "OrganisationID"); RelKeyDef relKeyDef = new RelKeyDef(); relKeyDef.Add(relPropDef); MultipleRelationshipDef relationshipDef = new MultipleRelationshipDef("ContactPeople", "Habanero.Test.BO", "ContactPersonTestBO", relKeyDef, true, "", DeleteParentAction.DeleteRelated, InsertParentAction.InsertRelationship, RelationshipType.Composition, 0); relationshipDef.ReverseRelationshipName = "Organisation"; itsClassDef.RelationshipDefCol.Add(relationshipDef); ClassDef.ClassDefs.Add(itsClassDef); return(itsClassDef); }
public static IClassDef LoadDefaultClassDef_SingleRel_NoReverseRelationship() { XmlClassLoader itsLoader = CreateXmlClassLoader(); IClassDef itsClassDef = itsLoader.LoadClass( @" <class name=""OrganisationTestBO"" assembly=""Habanero.Test.BO"" table=""organisation""> <property name=""OrganisationID"" type=""Guid"" /> <property name=""Name"" /> <primaryKey> <prop name=""OrganisationID"" /> </primaryKey> </class> " ); RelPropDef relPropDef = new RelPropDef(itsClassDef.PropDefcol["OrganisationID"], "OrganisationID"); RelKeyDef relKeyDef = new RelKeyDef(); relKeyDef.Add(relPropDef); IRelationshipDef relationshipDef = new SingleRelationshipDef("ContactPerson", "Habanero.Test.BO", "ContactPersonTestBO", relKeyDef, true, DeleteParentAction.DeleteRelated, InsertParentAction.InsertRelationship, RelationshipType.Aggregation); relationshipDef.OwningBOHasForeignKey = false; itsClassDef.RelationshipDefCol.Add(relationshipDef); ClassDef.ClassDefs.Add(itsClassDef); return(itsClassDef); }
public void TestColIsInstantiatedButNotLoaded() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); OrganisationTestBO.LoadDefaultClassDef(); IClassDef contactPersonClassDef = ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); RelKeyDef keyDef = new RelKeyDef(); keyDef.Add(new RelPropDef(contactPersonClassDef.PropDefcol["OrganisationID"], "OrganisationID")); MultipleRelationshipDef def = new MultipleRelationshipDef (TestUtil.GetRandomString(), typeof(ContactPersonTestBO), keyDef, false, "", DeleteParentAction.DoNothing); OrganisationTestBO organisation = new OrganisationTestBO(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IMultipleRelationship rel = (IMultipleRelationship)def.CreateRelationship(organisation, organisation.Props); //---------------Test Result ----------------------- IBusinessObjectCollection collection = rel.BusinessObjectCollection; Assert.IsNotNull(collection); Assert.AreEqual(0, collection.Count); Assert.AreSame(contactPersonClassDef, collection.ClassDef); Assert.IsNotNull(collection.SelectQuery.Criteria); Assert.IsNotNull(collection.SelectQuery.Criteria.Field); Assert.AreEqual("OrganisationID", collection.SelectQuery.Criteria.Field.PropertyName); Assert.IsNotNull(collection.SelectQuery.Criteria.Field.Source); Assert.AreEqual("ContactPersonTestBO", collection.SelectQuery.Criteria.Field.Source.Name); Assert.AreEqual(organisation.OrganisationID.Value, collection.SelectQuery.Criteria.FieldValue); Assert.IsInstanceOf(typeof(ContactPersonTestBO), collection.CreateBusinessObject()); }
private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol) { RelationshipDefCol relDefCol = new RelationshipDefCol(); //Define Owner Relationships RelKeyDef relKeyDef; IPropDef propDef; RelPropDef lRelPropDef; relKeyDef = new RelKeyDef(); propDef = lPropDefCol["ContactPersonID"]; lRelPropDef = new RelPropDef(propDef, "OwnerId"); relKeyDef.Add(lRelPropDef); //RelationshipDef relDef1 = new MultipleRelationshipDef("Owner", typeof(Car), // relKeyDef, false, "", // DeleteParentAction.DereferenceRelated); RelationshipDef relDef2 = new MultipleRelationshipDef("Cars", typeof(Car), relKeyDef, false, "Engine.EngineNo", DeleteParentAction.DereferenceRelated); //relDefCol.Add(relDef1); relDefCol.Add(relDef2); relKeyDef = new RelKeyDef(); // propDef = lPropDefCol["ContactPersonID"]; lRelPropDef = new RelPropDef(propDef, "ContactPersonID"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef3 = new MultipleRelationshipDef("Addresses", typeof(Address), relKeyDef, false, "", DeleteParentAction.DeleteRelated); relDefCol.Add(relDef3); return(relDefCol); }
private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol) { RelationshipDefCol relDefCol = new RelationshipDefCol(); //Define Owner Relationships RelKeyDef relKeyDef = new RelKeyDef(); IPropDef propDef = lPropDefCol["OwnerId"]; RelPropDef lRelPropDef = new RelPropDef(propDef, "ContactPersonID"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef = new SingleRelationshipDef("Owner", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.Prevent); relDefCol.Add(relDef); //Define Driver Relationships relKeyDef = new RelKeyDef(); propDef = lPropDefCol["DriverFK1"]; lRelPropDef = new RelPropDef(propDef, "PK1Prop1"); relKeyDef.Add(lRelPropDef); propDef = lPropDefCol["DriverFK2"]; lRelPropDef = new RelPropDef(propDef, "PK1Prop2"); relKeyDef.Add(lRelPropDef); relDef = new SingleRelationshipDef("Driver", typeof(ContactPersonCompositeKey), relKeyDef, true, DeleteParentAction.Prevent); relDefCol.Add(relDef); //Define Engine Relationships relKeyDef = new RelKeyDef(); propDef = lPropDefCol["CarID"]; lRelPropDef = new RelPropDef(propDef, "CarID"); relKeyDef.Add(lRelPropDef); relDef = new SingleRelationshipDef("Engine", typeof(Engine), relKeyDef, false, DeleteParentAction.DereferenceRelated) { OwningBOHasForeignKey = false }; relDefCol.Add(relDef); return(relDefCol); }
public void Setup() { ClassDef.ClassDefs.Clear(); mRelKeyDef = new RelKeyDef(); mPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Prop", typeof(string), PropReadWriteRule.ReadWrite, "1"); mPropDefCol.Add(propDef); RelPropDef lRelPropDef = new RelPropDef(propDef, "PropName"); mRelKeyDef.Add(lRelPropDef); propDef = new PropDef("Prop2", typeof(string), PropReadWriteRule.ReadWrite, "2"); mPropDefCol.Add(propDef); lRelPropDef = new RelPropDef(propDef, "PropName2"); mRelKeyDef.Add(lRelPropDef); }
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); }
public void AddPreventDeleteRelationship() { RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef lRelPropDef = new RelPropDef(ClassDef.PropDefcol["ContactPersonID"], "ContactPersonID"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef = new MultipleRelationshipDef("AddressesNoDelete", typeof(Address), relKeyDef, false, "", DeleteParentAction.Prevent); ClassDef.RelationshipDefCol = new RelationshipDefCol(); ClassDef.RelationshipDefCol.Add(relDef); Relationships.Add(new MultipleRelationship <Address>(this, relDef, Props)); }
public void Test_Contains_WhenNotHas_ShouldReturnFalse() { //---------------Set up test pack------------------- var relKeyDef = new RelKeyDef(); const string ownerClassPropDefName = "fdafads"; IRelPropDef relPropDef = new RelPropDef(ownerClassPropDefName, "fdafasd"); relKeyDef.Add(relPropDef); //---------------Assert Precondition---------------- Assert.AreEqual(1, relKeyDef.Count); //---------------Execute Test ---------------------- var contains = relKeyDef.Contains("SomeOtherName"); //---------------Test Result ----------------------- Assert.IsFalse(contains); }
public static ClassDef CreateClassDefWithShapeRelationship() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDef lKeyDef = new KeyDef(); lKeyDef.IgnoreIfNull = true; lKeyDef.Add(lPropDefCol["PK2Prop1"]); lKeyDef.Add(lPropDefCol["PK2Prop2"]); KeyDefCol keysCol = new KeyDefCol(); keysCol.Add(lKeyDef); lKeyDef = new KeyDef(); lKeyDef.IgnoreIfNull = false; lKeyDef.Add(lPropDefCol["PK3Prop"]); keysCol.Add(lKeyDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["ContactPersonID"]); //Releationships RelationshipDefCol relDefs = new RelationshipDefCol(); RelKeyDef relKeyDef = new RelKeyDef(); IPropDef propDef = lPropDefCol["ContactPersonID"]; RelPropDef lRelPropDef = new RelPropDef(propDef, "OwnerId"); relKeyDef.Add(lRelPropDef); RelationshipDef relDef = new MultipleRelationshipDef("Shapes", typeof(Shape), relKeyDef, false, "", DeleteParentAction.DereferenceRelated); //relDefCol.Add(relDef1); relDefs.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(ContactPerson), primaryKey, "contact_person", lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
public void TestAddNullException() { //---------------Set up test pack------------------- RelKeyDef col = new RelKeyDef(); //---------------Execute Test ---------------------- try { col.Add(null); Assert.Fail("Expected to throw an HabaneroArgumentException"); } //---------------Test Result ----------------------- catch (HabaneroArgumentException ex) { StringAssert.Contains("You cannot add a null prop def to a classdef", ex.Message); } }
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(); }
private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol) { RelationshipDefCol relDefCol = new RelationshipDefCol(); //Define Relationships RelKeyDef relKeyDef = new RelKeyDef(); IPropDef propDef = lPropDefCol["ContactPersonID"]; RelPropDef relPropDef = new RelPropDef(propDef, "ContactPersonID"); relKeyDef.Add(relPropDef); RelationshipDef relDef = new SingleRelationshipDef("ContactPerson", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.Prevent); relDefCol.Add(relDef); return(relDefCol); }
public void TestFieldDefaultLabelFromRelatedClassDef() { ClassDef.ClassDefs.Clear(); ClassDef classDef = CreateTestClassDef(""); ClassDef classDef2 = CreateTestClassDef("2"); ClassDef.ClassDefs.Add(classDef2); RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef relPropDef = new RelPropDef(classDef.PropDefcol["TestProperty"], "TestProperty2"); relKeyDef.Add(relPropDef); SingleRelationshipDef def = new SingleRelationshipDef("TestRel", classDef2.AssemblyName, classDef2.ClassName, relKeyDef, false, DeleteParentAction.Prevent); classDef.RelationshipDefCol.Add(def); UIFormField uiFormField = new UIFormField(null, "TestRel.TestProperty2", typeof(TextBox), null, null, true, null, null, LayoutStyle.Label); Assert.AreEqual("Tested Property2:", uiFormField.GetLabel(classDef)); }
public void Test_IsCompulsory_WhenOwnerPropDefNull_ShouldRetFalse() { //---------------Set up test pack------------------- FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef(); var relKeyDef = new RelKeyDef(); IRelPropDef relPropDef = MockRepository.GenerateStub <IRelPropDef>(); relPropDef.Stub(def => def.OwnerPropertyName).Return(TestUtil.GetRandomString()); relKeyDef.Add(relPropDef); relationshipDef.SetRelKeyDef(relKeyDef); relationshipDef.OwningBOHasForeignKey = true; //---------------Assert Precondition---------------- Assert.IsTrue(relationshipDef.OwningBOHasForeignKey); Assert.IsNull(relPropDef.OwnerPropDef); //---------------Execute Test ---------------------- bool isCompulsory = relationshipDef.IsCompulsory; //---------------Test Result ----------------------- Assert.IsFalse(isCompulsory, "Rel Should not be compulsory"); }
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(); }
public void Test_IsCompulsory_WhenPropCompButNotOwningBoHasFK_ShouldRetFalse() { //---------------Set up test pack------------------- FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef(); var relKeyDef = new RelKeyDef(); var propDef = new PropDefFake { Compulsory = true }; var relPropDef = new RelPropDef(propDef, "SomeThing"); relKeyDef.Add(relPropDef); relationshipDef.SetRelKeyDef(relKeyDef); relationshipDef.OwningBOHasForeignKey = false; //---------------Assert Precondition---------------- Assert.IsTrue(propDef.Compulsory); Assert.IsFalse(relationshipDef.OwningBOHasForeignKey); //---------------Execute Test ---------------------- bool isCompulsory = relationshipDef.IsCompulsory; //---------------Test Result ----------------------- Assert.IsFalse(isCompulsory, "Rel Should not be compulsory"); }
public void TestFieldDefaultLabelFromRelatedClassDef() { ClassDef.ClassDefs.Clear(); ClassDef classDef = CreateTestClassDef(""); ClassDef classDef2 = CreateTestClassDef("2"); ClassDef.ClassDefs.Add(classDef2); RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef relPropDef = new RelPropDef(classDef.PropDefcol["TestProperty"], "TestProperty2"); relKeyDef.Add(relPropDef); SingleRelationshipDef def = new SingleRelationshipDef("TestRel", classDef2.AssemblyName, classDef2.ClassName, relKeyDef, false, DeleteParentAction.Prevent); classDef.RelationshipDefCol.Add(def); UIGridColumn uiGridColumn; uiGridColumn = new UIGridColumn(null, "TestRel.TestProperty2", typeof(DataGridViewTextBoxColumn), false, 100, PropAlignment.left, null); #pragma warning disable 612,618 Assert.AreEqual("Tested Property2", uiGridColumn.GetHeading(classDef)); #pragma warning restore 612,618 }
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 Test_IsCompulsory_WhenNotHasCompulsoryFKProps_ShouldReturnFalse() { FakeSingleRelationshipDef singleRelationshipDef = new FakeSingleRelationshipDef(); var relKeyDef = new RelKeyDef(); var propDef = new PropDefFake { Compulsory = false }; var relPropDef = new RelPropDef(propDef, "SomeThing"); relKeyDef.Add(relPropDef); singleRelationshipDef.SetRelKeyDef(relKeyDef); singleRelationshipDef.OwningBOHasForeignKey = true; IRelationshipDef relationshipDef = singleRelationshipDef; //---------------Assert Precondition---------------- Assert.IsFalse(propDef.Compulsory); Assert.IsTrue(singleRelationshipDef.OwningBOHasForeignKey); //---------------Execute Test ---------------------- bool isCompulsory = relationshipDef.IsCompulsory; //---------------Test Result ----------------------- Assert.IsFalse(isCompulsory); }
private static ClassDef CreateClassDef(long number, bool hasSingleRelationship, bool hasMultipleRelationship, bool hasMultipleRelationshipWithPreventDelete) { const string assemblyName = "Habanero.Test.BO"; const string className = "TestBO"; const string idPropName = "MyBoID"; const string fkPropertyName = "MyParentBoID"; string suffix = number.ToString(); PropDefCol propDefCol = new PropDefCol(); PrimaryKeyDef primaryKeyDef = new PrimaryKeyDef(); primaryKeyDef.IsGuidObjectID = false; RelationshipDefCol relationshipDefCol = new RelationshipDefCol(); PropDef idPropDef = new PropDef(idPropName, typeof(string), PropReadWriteRule.ReadWrite, ""); propDefCol.Add(idPropDef); primaryKeyDef.Add(idPropDef); //propDef = new PropDef("MyProp", typeof(string), PropReadWriteRule.ReadWrite, "" ); //propDefCol.Add(propDef); PropDef propDef = new PropDef(fkPropertyName, typeof(string), PropReadWriteRule.ReadWrite, ""); propDefCol.Add(propDef); if (hasSingleRelationship) { string relatedClassSuffix = (number - 1).ToString(); RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef relPropDef = new RelPropDef(propDef, idPropName); relKeyDef.Add(relPropDef); SingleRelationshipDef singleRelationshipDef = new SingleRelationshipDef( "MyParent", assemblyName, className + relatedClassSuffix, relKeyDef, false, DeleteParentAction.Prevent); relationshipDefCol.Add(singleRelationshipDef); } if (hasMultipleRelationship) { string relatedClassSuffix = (number + 1).ToString(); RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef relPropDef = new RelPropDef(idPropDef, fkPropertyName); relKeyDef.Add(relPropDef); MultipleRelationshipDef multipleRelationshipDef = new MultipleRelationshipDef("MyBO" + relatedClassSuffix, assemblyName, className + relatedClassSuffix, relKeyDef, false, "", DeleteParentAction.DeleteRelated); relationshipDefCol.Add(multipleRelationshipDef); } if (hasMultipleRelationshipWithPreventDelete) { string relatedClassSuffix = (number + 1).ToString(); RelKeyDef relKeyDef = new RelKeyDef(); RelPropDef relPropDef = new RelPropDef(idPropDef, fkPropertyName); relKeyDef.Add(relPropDef); MultipleRelationshipDef multipleRelationshipDef = new MultipleRelationshipDef("MyPreventBO" + relatedClassSuffix, assemblyName, className + relatedClassSuffix, relKeyDef, false, "", DeleteParentAction.Prevent); relationshipDefCol.Add(multipleRelationshipDef); } ClassDef classDef = new ClassDef(assemblyName, className + suffix, primaryKeyDef, propDefCol, new KeyDefCol(), relationshipDefCol, new UIDefCol()); return(classDef); }