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 void SetupRelationshipDefCol() { foreach (var singleRelationshipDefBuilder in _singleRelationshipDefBuilders) { var singleRelationshipDef = singleRelationshipDefBuilder.Build(); CheckOwnerProps(singleRelationshipDef.RelKeyDef); _relationshipDefCol.Add(singleRelationshipDef); } foreach (var multipleRelationshipDefBuilder in _multipleRelationshipDefBuilders) { var multipleRelationshipDef = multipleRelationshipDefBuilder.Build(); CheckOwnerProps(multipleRelationshipDef.RelKeyDef); _relationshipDefCol.Add(multipleRelationshipDef); } }
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); }
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 TestAddDuplicationException() { //---------------Set up test pack------------------- SingleRelationshipDef relDef = new SingleRelationshipDef("rel", typeof(MyRelatedBo), new RelKeyDef(), true, DeleteParentAction.Prevent); RelationshipDefCol col = new RelationshipDefCol(); col.Add(relDef); //---------------Execute Test ---------------------- try { col.Add(relDef); Assert.Fail("Expected to throw an ArgumentException"); } //---------------Test Result ----------------------- catch (ArgumentException ex) { StringAssert.Contains("A relationship definition with the name 'rel' already exists", ex.Message); } }
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); }
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); }
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); }