/// <summary> /// Loads the RelKeyDef information from the reader. This method /// is called by LoadFromReader(). /// </summary> private void LoadRelKeyDef() { _relKeyDef = _defClassFactory.CreateRelKeyDef(); while (_reader.Name == "relatedProperty") { string propName = _reader.GetAttribute("property"); string relPropName = _reader.GetAttribute("relatedProperty"); if (string.IsNullOrEmpty(propName)) { throw new InvalidXmlDefinitionException ("A 'relatedProperty' element " + "is missing the 'property' attribute, which specifies the " + "property in this class to which the " + "relationship will link."); } if (string.IsNullOrEmpty(relPropName)) { throw new InvalidXmlDefinitionException ("A 'relatedProperty' element " + "is missing the 'relatedProperty' attribute, which specifies the " + "property in the related class to which the " + "relationship will link."); } //if (!_propDefCol.Contains(propName)) //{ // throw new InvalidXmlDefinitionException // (string.Format // ("The property '{0}' defined in the " + "'relatedProperty' element " // + "in its 'Property' attribute, which specifies the " // + "property in the class '{1}' from which the " // + "relationship '{2}' will link is not defined in the class '{1}'.", propName, _className, // _name)); //} _relKeyDef.Add(_defClassFactory.CreateRelPropDef(propName, relPropName)); ReadAndIgnoreEndTag(); } }
private void CheckOwnerProps(IRelKeyDef relPropDefs) { foreach (var relPropDef in relPropDefs) { UpdatePropDefCol(relPropDef.OwnerPropertyName, false); } }
/// <summary> /// Constructor to create a new relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectClassType">The class type of the related object</param> /// <param name="relKeyDef">The related key definition</param> /// <param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> /// <param name="deleteParentAction">The required action when the parent is deleted e.g. Dereference related, delete related, prevent delete</param> protected RelationshipDef(string relationshipName, Type relatedObjectClassType, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction) : this(relationshipName, relatedObjectClassType, null, null, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, InsertParentAction.InsertRelationship, RelationshipType.Association) { }
// ReSharper restore DoNotCallOverridableMethodsInConstructor /// <summary> /// Constructor to create a new single relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectAssemblyName">The assembly name of the related object</param> /// <param name="relatedObjectClassName">The class name of the related object</param> /// <param name="relKeyDef">The related key definition</param> /// <param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> /// <param name="deleteParentAction"></param> public SingleRelationshipDef (string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction) : this( relationshipName, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, InsertParentAction.InsertRelationship, RelationshipType.Association) { }
// ReSharper restore DoNotCallOverridableMethodsInConstructor /// <summary> /// Constructor to create a new single relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectAssemblyName">The assembly name of the related object</param> /// <param name="relatedObjectClassName">The class name of the related object</param> /// <param name="relKeyDef">The related key definition</param> /// <param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> /// <param name="deleteParentAction"></param> public SingleRelationshipDef (string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction) : this( relationshipName, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, InsertParentAction.InsertRelationship, RelationshipType.Association) { }
/// <summary> /// Constructor to create a new relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectClassType">The class type of the related object</param> /// <param name="relKeyDef">The related key definition</param> /// <param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> /// <param name="deleteParentAction">The required action when the parent is deleted e.g. Dereference related, delete related, prevent delete</param> protected RelationshipDef(string relationshipName, Type relatedObjectClassType, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction) : this(relationshipName, relatedObjectClassType, null, null, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, InsertParentAction.InsertRelationship, RelationshipType.Association) { }
// ReSharper disable DoNotCallOverridableMethodsInConstructor ///<summary> /// Constructs a single Relationship ///</summary> ///<param name="relationshipName"></param> ///<param name="relatedObjectAssemblyName"></param> ///<param name="relatedObjectClassName"></param> ///<param name="relKeyDef"></param> ///<param name="keepReferenceToRelatedObject"></param> ///<param name="deleteParentAction"></param> ///<param name="insertParentAction"><see cref="InsertParentAction"/></param> ///<param name="relationshipType"></param> public SingleRelationshipDef(string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) : base( relationshipName, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, insertParentAction, relationshipType) { OwningBOHasForeignKey = true; }
public ISingleRelationshipDef Build() { //_relKeyDef = _relKeyBuilder.Build(); if (this.SingleRelKeyDefBuilder == null) { this.SingleRelKeyDefBuilder = new SingleRelKeyDefBuilder <T, TRelatedType>(this); } _relKeyDef = this.SingleRelKeyDefBuilder.Build(); return(new SingleRelationshipDef(RelationshipName, _relatedObjectAssemblyName, _relatedClassName, _relKeyDef, KeepReference, DeleteAction, InsertAction, RelType)); }
public IRelationshipDef Build() { if (this.MultipleRelKeyDefBuilder == null) { this.MultipleRelKeyDefBuilder = new MultipleRelKeyDefBuilder <T, TRelatedType>(this); } _relKeyDef = this.MultipleRelKeyDefBuilder.Build(); return(new MultipleRelationshipDef(_relationshipName, _relatedObjectAssemblyName, _relatedClassName, _relKeyDef, _keepReference, _orderBy, _deleteAction, _insertAction, _relationshipType, _timeOut)); }
/// <summary> /// Constructor to create a new single relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectAssemblyName">The assembly name of the related object</param> /// <param name="relatedObjectClassName">The class name of the related object</param> /// <param name="relKeyDef">The related key definition</param> /// <param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> /// <param name="orderBy">The sql order-by clause</param> /// <param name="deleteParentAction">Provides specific instructions /// with regards to deleting a parent object. See the DeleteParentAction /// enumeration for more detail.</param> public MultipleRelationshipDef(string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, string orderBy, DeleteParentAction deleteParentAction) : base(relationshipName, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, InsertParentAction.InsertRelationship, RelationshipType.Association) { ArgumentValidationHelper.CheckArgumentNotNull(orderBy, "orderBy"); OrderCriteriaString = orderBy; OrderCriteria = Base.OrderCriteria.FromString(orderBy); }
/// <summary> /// Constructor to create a new single relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectAssemblyName">The assembly name of the related object</param> /// <param name="relatedObjectClassName">The class name of the related object</param> /// <param name="relKeyDef">The related key definition</param> /// <param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> /// <param name="orderBy">The sql order-by clause</param> /// <param name="deleteParentAction">Provides specific instructions /// with regards to deleting a parent object. See the DeleteParentAction /// enumeration for more detail.</param> public MultipleRelationshipDef(string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, string orderBy, DeleteParentAction deleteParentAction) : base(relationshipName, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, InsertParentAction.InsertRelationship, RelationshipType.Association) { ArgumentValidationHelper.CheckArgumentNotNull(orderBy, "orderBy"); OrderCriteriaString = orderBy; OrderCriteria = Base.OrderCriteria.FromString(orderBy); }
private void SetupDefaultValues() { _deleteAction = DeleteParentAction.DoNothing; _insertAction = InsertParentAction.InsertRelationship; _relationshipType = RelationshipType.Association; _keepReference = true; _orderBy = ""; Type type = typeof(TRelatedType); _relatedObjectAssemblyName = type.Namespace; _relatedClassName = type.Name; _relKeyDef = new RelKeyDef(); _timeOut = 0; }
public void Test_IsCompulsory_WhenRelKeyDefNull_ShouldRetFalse() { //---------------Set up test pack------------------- FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef(); IRelKeyDef relKeyDef = null; relationshipDef.SetRelKeyDef(relKeyDef); relationshipDef.OwningBOHasForeignKey = true; //---------------Assert Precondition---------------- Assert.IsTrue(relationshipDef.OwningBOHasForeignKey); //---------------Execute Test ---------------------- bool isCompulsory = relationshipDef.IsCompulsory; //---------------Test Result ----------------------- Assert.IsFalse(isCompulsory, "Rel Should not be compulsory"); }
// ReSharper disable DoNotCallOverridableMethodsInConstructor private RelationshipDef(string relationshipName, Type relatedObjectClassType, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) { ArgumentValidationHelper.CheckArgumentNotNull(relKeyDef, "relKeyDef"); ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName"); if (relatedObjectClassType != null) { MyRelatedObjectClassType = relatedObjectClassType; } else { _relatedObjectAssemblyName = relatedObjectAssemblyName; _relatedObjectClassName = relatedObjectClassName; _relatedObjectClassType = null; } RelKeyDef = relKeyDef; RelationshipName = relationshipName; KeepReferenceToRelatedObject = keepReferenceToRelatedObject; this.DeleteParentAction = deleteParentAction; this.InsertParentAction = insertParentAction; RelationshipType = relationshipType; }
// ReSharper disable DoNotCallOverridableMethodsInConstructor ///<summary> /// Constructs a single Relationship ///</summary> ///<param name="relationshipName"></param> ///<param name="relatedObjectAssemblyName"></param> ///<param name="relatedObjectClassName"></param> ///<param name="relKeyDef"></param> ///<param name="keepReferenceToRelatedObject"></param> ///<param name="deleteParentAction"></param> ///<param name="insertParentAction"><see cref="InsertParentAction"/></param> ///<param name="relationshipType"></param> public SingleRelationshipDef(string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) : base( relationshipName, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, insertParentAction, relationshipType) { OwningBOHasForeignKey = true; }
public void SetRelKeyDef(IRelKeyDef relKeyDef) { RelKeyDef = relKeyDef; }
/// <summary> /// Loads the RelKeyDef information from the reader. This method /// is called by LoadFromReader(). /// </summary> private void LoadRelKeyDef() { _relKeyDef = _defClassFactory.CreateRelKeyDef(); while (_reader.Name == "relatedProperty") { string propName = _reader.GetAttribute("property"); string relPropName = _reader.GetAttribute("relatedProperty"); if (string.IsNullOrEmpty(propName)) { throw new InvalidXmlDefinitionException ("A 'relatedProperty' element " + "is missing the 'property' attribute, which specifies the " + "property in this class to which the " + "relationship will link."); } if (string.IsNullOrEmpty(relPropName)) { throw new InvalidXmlDefinitionException ("A 'relatedProperty' element " + "is missing the 'relatedProperty' attribute, which specifies the " + "property in the related class to which the " + "relationship will link."); } //if (!_propDefCol.Contains(propName)) //{ // throw new InvalidXmlDefinitionException // (string.Format // ("The property '{0}' defined in the " + "'relatedProperty' element " // + "in its 'Property' attribute, which specifies the " // + "property in the class '{1}' from which the " // + "relationship '{2}' will link is not defined in the class '{1}'.", propName, _className, // _name)); //} _relKeyDef.Add(_defClassFactory.CreateRelPropDef(propName, relPropName)); ReadAndIgnoreEndTag(); } }
///<summary> ///</summary> ///<param name="relationshipName"></param> ///<param name="relatedAssemblyName"></param> ///<param name="relatedClassName"></param> ///<param name="relKeyDef"></param> ///<param name="keepReferenceToRelatedObject"></param> ///<param name="deleteParentAction"></param> ///<param name="insertParentAction"><see cref="InsertParentAction"/></param> ///<param name="relationshipType"></param> ///<returns></returns> public IRelationshipDef CreateSingleRelationshipDef (string relationshipName, string relatedAssemblyName, string relatedClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) { return new SingleRelationshipDef(relationshipName, relatedAssemblyName, relatedClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, insertParentAction, relationshipType); }
///<summary> ///</summary> ///<param name="relationshipName"></param> ///<param name="relatedAssemblyName"></param> ///<param name="relatedClassName"></param> ///<param name="relKeyDef"></param> ///<param name="keepReferenceToRelatedObject"></param> ///<param name="orderBy"></param> ///<param name="deleteParentAction"></param> ///<param name="insertParentAction"><see cref="InsertParentAction"/></param> ///<param name="relationshipType"></param> ///<param name="timeout">The timout in milliseconds. The collection will not be automatically refreshed from the DB if the timeout has not expired</param> ///<returns></returns> public IRelationshipDef CreateMultipleRelationshipDef (string relationshipName, string relatedAssemblyName, string relatedClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, string orderBy, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType, int timeout) { return new MultipleRelationshipDef(relationshipName, relatedAssemblyName, relatedClassName, relKeyDef, keepReferenceToRelatedObject, orderBy, deleteParentAction, insertParentAction, relationshipType, timeout); }
public void SetRelKeyDef(IRelKeyDef relKeyDef) { RelKeyDef = relKeyDef; }
/// <summary> /// Constructor to create a new relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectAssemblyName">The assembly that the related object is in</param> /// <param name="relatedObjectClassName">The class type of the related object</param> /// <param name="relKeyDef">The related key definition</param> ///<param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> ///<param name="deleteParentAction">The required action when the parent is deleted e.g. Dereference related, delete related, prevent delete</param> /// <param name="insertParentAction"><see cref="InsertParentAction"/></param> /// <param name="relationshipType"></param> protected RelationshipDef(string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) : this(relationshipName, null, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, insertParentAction, relationshipType) { }
// ReSharper disable DoNotCallOverridableMethodsInConstructor private RelationshipDef(string relationshipName, Type relatedObjectClassType, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) { ArgumentValidationHelper.CheckArgumentNotNull(relKeyDef, "relKeyDef"); ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName"); if (relatedObjectClassType != null) MyRelatedObjectClassType = relatedObjectClassType; else { _relatedObjectAssemblyName = relatedObjectAssemblyName; _relatedObjectClassName = relatedObjectClassName; _relatedObjectClassType = null; } RelKeyDef = relKeyDef; RelationshipName = relationshipName; KeepReferenceToRelatedObject = keepReferenceToRelatedObject; this.DeleteParentAction = deleteParentAction; this.InsertParentAction = insertParentAction; RelationshipType = relationshipType; }
///<summary> ///</summary> ///<param name="relationshipName"></param> ///<param name="relatedAssemblyName"></param> ///<param name="relatedClassName"></param> ///<param name="relKeyDef"></param> ///<param name="keepReferenceToRelatedObject"></param> ///<param name="orderBy"></param> ///<param name="deleteParentAction"></param> ///<param name="insertParentAction"><see cref="InsertParentAction"/></param> ///<param name="relationshipType"></param> ///<param name="timeout">The timout in milliseconds. The collection will not be automatically refreshed from the DB if the timeout has not expired</param> ///<returns></returns> public IRelationshipDef CreateMultipleRelationshipDef (string relationshipName, string relatedAssemblyName, string relatedClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, string orderBy, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType, int timeout) { return (new MultipleRelationshipDef(relationshipName, relatedAssemblyName, relatedClassName, relKeyDef, keepReferenceToRelatedObject, orderBy, deleteParentAction, insertParentAction, relationshipType, timeout)); }
/// <summary> /// Constructor to create a new relationship definition /// </summary> /// <param name="relationshipName">A name for the relationship</param> /// <param name="relatedObjectAssemblyName">The assembly that the related object is in</param> /// <param name="relatedObjectClassName">The class type of the related object</param> /// <param name="relKeyDef">The related key definition</param> ///<param name="keepReferenceToRelatedObject">Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.</param> ///<param name="deleteParentAction">The required action when the parent is deleted e.g. Dereference related, delete related, prevent delete</param> /// <param name="insertParentAction"><see cref="InsertParentAction"/></param> /// <param name="relationshipType"></param> protected RelationshipDef(string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) : this(relationshipName, null, relatedObjectAssemblyName, relatedObjectClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, insertParentAction, relationshipType) { }
///<summary> ///</summary> ///<param name="relationshipName"></param> ///<param name="relatedAssemblyName"></param> ///<param name="relatedClassName"></param> ///<param name="relKeyDef"></param> ///<param name="keepReferenceToRelatedObject"></param> ///<param name="deleteParentAction"></param> ///<param name="insertParentAction"><see cref="InsertParentAction"/></param> ///<param name="relationshipType"></param> ///<returns></returns> public IRelationshipDef CreateSingleRelationshipDef (string relationshipName, string relatedAssemblyName, string relatedClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType) { return (new SingleRelationshipDef(relationshipName, relatedAssemblyName, relatedClassName, relKeyDef, keepReferenceToRelatedObject, deleteParentAction, insertParentAction, relationshipType)); }