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; 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 new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Radius", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); //propDef = new PropDef("ContactPersonID", typeof(Guid), PropReadWriteRule.WriteOnce, "ContactPersonID", null); //lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); //RelKeyDef relKeyDef = new RelKeyDef(); //IPropDef relPropDef = lPropDefCol["ContactPersonID"]; //RelPropDef lRelPropDef = new RelPropDef(relPropDef, "ContactPersonID"); //relKeyDef.Add(lRelPropDef); //RelationshipDef relDef = new SingleRelationshipDef("ContactPerson", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.DoNothing); //relDefCol.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(CircleNoPrimaryKey), null, "circle_table", lPropDefCol, keysCol, relDefCol, null); //ClassDef lClassDef = new ClassDef(typeof(CircleNoPrimaryKey), null, lPropDefCol, keysCol, relDefCol); lClassDef.SuperClassDef = new SuperClassDef(Shape.GetClassDef(), ORMapping.ClassTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
private static ClassDef CreateClassDef() { 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 = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof(ContactPerson), primaryKey, "contact_person", lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
private void Initialise() { _propDefCol = new PropDefCol(); //PropDefBuilders = new List<PropDefBuilder<T>>(); _propertiesDefBuilder = new PropertiesDefBuilder <T>(this, PropDefBuilders); _relationshipDefCol = new RelationshipDefCol(); _primaryKeyDef = new PrimaryKeyDef(); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); //ClassDef lClassDef = new ClassDef(typeof(FilledCircleInheritsCircleNoPK), primaryKey, lPropDefCol, keysCol, relDefCol); ClassDef lClassDef = new ClassDef(typeof(FakeSubClass), null, lPropDefCol, keysCol, relDefCol, null); lClassDef.SuperClassDef = new SuperClassDef(FakeSuperClass.GetClassDef(), ORMapping.SingleTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("SomeNewProp", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); ClassDef lClassDef = new ClassDef(typeof(BOWithIntID_Child), null, "bowithintid", lPropDefCol, keysCol, relDefCol, null); return(lClassDef); }
public void Test_SetClassDef_ShouldSet() { //---------------Set up test pack------------------- var classDef = MockRepository.GenerateStub <IClassDef>(); IRelationshipDefCol col = new RelationshipDefCol(); //---------------Assert Precondition---------------- Assert.IsNull(col.ClassDef); //---------------Execute Test ---------------------- col.ClassDef = classDef; //---------------Test Result ----------------------- Assert.AreSame(classDef, col.ClassDef); }
private new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Colour", typeof(int), PropReadWriteRule.ReadWrite, "Colour", null); lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); //ClassDef lClassDef = new ClassDef(typeof (FilledCircleNoPrimaryKeyInheritsCircle), null, lPropDefCol, keysCol, relDefCol); ClassDef lClassDef = new ClassDef(typeof(FilledCircleNoPrimaryKeyInheritsCircle), null, "FilledCircle_table", lPropDefCol, keysCol, relDefCol, null); lClassDef.SuperClassDef = new SuperClassDef(Circle.GetClassDef(), ORMapping.ConcreteTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
public void TestThisIndexerException() { //---------------Set up test pack------------------- RelationshipDefCol col = new RelationshipDefCol(); //---------------Execute Test ---------------------- try { IRelationshipDef relDef = col["rel"]; Assert.Fail("Expected to throw an ArgumentException"); } //---------------Test Result ----------------------- catch (ArgumentException ex) { StringAssert.Contains("The relationship name 'rel' does not exist in the collection of relationship definitions", 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 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); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); var keysCol = new KeyDefCol(); var primaryKey = new PrimaryKeyDef { IsGuidObjectID = false }; primaryKey.Add(lPropDefCol[PK1_PROP1_NAME]); var relDefs = new RelationshipDefCol(); var lClassDef = new ClassDef(typeof(BOWithCompositePK), primaryKey, 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() { PropDefCol propDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(propDefCol["AddressID"]); RelationshipDefCol relDefCol = CreateRelationshipDefCol(propDefCol); ClassDef classDef = new ClassDef(typeof(Address), primaryKey, "contact_person_address", propDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(classDef); return(classDef); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); IPropDef propDef = new PropDef("FakeSuperClassID", typeof(Guid), PropReadWriteRule.WriteOnce, null); lPropDefCol.Add(propDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef { IsGuidObjectID = true }; primaryKey.Add(lPropDefCol["FakeSuperClassID"]); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); ClassDef lClassDef = new ClassDef(typeof(FakeSuperClass), primaryKey, lPropDefCol, keysCol, relDefCol, null); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef { IsGuidObjectID = false }; primaryKey.Add(lPropDefCol[PK1_PROP1_NAME]); primaryKey.Add(lPropDefCol[PK1_PROP2_NAME]); RelationshipDefCol relDefs = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof(ContactPersonCompositeKey), primaryKey, lPropDefCol, keysCol, relDefs); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
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); } }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["EngineID"]); RelationshipDefCol relDefCol = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof(Engine), primaryKey, lPropDefCol, keysCol, relDefCol); lClassDef.TableName = "Table_Engine"; ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = CreateBOPropDef(); KeyDefCol keysCol = new KeyDefCol(); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["CarID"]); RelationshipDefCol relDefCol = CreateRelationshipDefCol(lPropDefCol); ClassDef lClassDef = new ClassDef(typeof(Car), primaryKey, "car_table", lPropDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
private new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); IPropDef propDef = new PropDef("Colour", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = lPropDefCol.Add("FilledCircleID", typeof(Guid), PropReadWriteRule.WriteOnce, "FilledCircleID_field", null); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["FilledCircleID"]); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); ClassDef lClassDef = new ClassDef(typeof(FilledCircle), primaryKey, "FilledCircle_table", lPropDefCol, keysCol, relDefCol); lClassDef.SuperClassDef = new SuperClassDef(Circle.GetClassDef(), ORMapping.ConcreteTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
public static ClassDef CreateTestMapperClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("ShapeName", typeof(String), PropReadWriteRule.ReadWrite, "ShapeName", null); lPropDefCol.Add(propDef); propDef = new PropDef("ShapeID", typeof(Guid), PropReadWriteRule.WriteOnce, "ShapeID_field", null); lPropDefCol.Add(propDef); propDef = new PropDef("ShapeValue", typeof(Int32), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); // propDef = new PropDef("MyID", typeof(Guid), PropReadWriteRule.WriteOnce, null); // lPropDefCol.Add(propDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["ShapeID"]); KeyDefCol keysCol = new KeyDefCol(); KeyDef lKeyDef = new KeyDef(); lKeyDef.Add(lPropDefCol["ShapeName"]); keysCol.Add(lKeyDef); // RelKeyDef relKeyDef = new RelKeyDef(); //RelPropDef lRelPropDef = new RelPropDef(propDef, "OwnerID"); //relKeyDef.Add(lRelPropDef); //RelationshipDef relDef = new MultipleRelationshipDef("Owner", typeof (Shape), // relKeyDef, false, "", DeleteParentAction.DereferenceRelated); RelationshipDefCol relDefCol = new RelationshipDefCol(); //relDefCol.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(Shape), primaryKey, "Shape_table", lPropDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
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); }