Ejemplo n.º 1
0
        /// <summary>
        /// Returns the business object that is related to this object
        /// through the specified relationship (eg. would return a father
        /// if the relationship was called "father").  This method is to be
        /// used in the case of single relationships.
        /// </summary>
        /// <param name="relationshipName">The name of the relationship</param>
        /// <returns>Returns a business object</returns>
        /// <exception cref="InvalidRelationshipAccessException">Thrown if
        /// the relationship specified is a multiple relationship, when a
        /// single one was expected</exception>
        public T GetRelatedObject <T>(string relationshipName) where T : class, IBusinessObject, new()
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            SingleRelationship <T> relationship = GetSingle <T>(relationshipName);

            return(relationship.GetRelatedObject());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Loads a business object of type T using the relationship given. The relationship will be converted into a
 /// Criteria object that defines the relationship and this will be used to load the related object.
 /// </summary>
 /// <typeparam name="T">The type of the business object to load</typeparam>
 /// <param name="relationship">The relationship to use to load the object</param>
 /// <returns>An object of type T if one was found, otherwise null</returns>
 public T GetRelatedBusinessObject <T>(SingleRelationship <T> relationship) where T : class, IBusinessObject, new()
 {
     if (_businessObjectLoaders.ContainsKey(typeof(T)))
     {
         return(_businessObjectLoaders[typeof(T)].GetRelatedBusinessObject(relationship));
     }
     return(_defaultBusinessObjectLoader.GetRelatedBusinessObject(relationship));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Loads a business object of type T using the relationship given. The relationship will be converted into a
 /// Criteria object that defines the relationship and this will be used to load the related object.
 /// </summary>
 /// <typeparam name="T">The type of the business object to load</typeparam>
 /// <param name="relationship">The relationship to use to load the object</param>
 /// <returns>An object of type T if one was found, otherwise null</returns>
 public static T GetRelatedBusinessObject <T>(SingleRelationship <T> relationship) where T : class, IBusinessObject, new()
 {
     return(BORegistry.DataAccessor.BusinessObjectLoader.GetRelatedBusinessObject(relationship));
 }
 /// <summary>
 /// Loads a business object of type T using the relationship given. The relationship will be converted into a
 /// Criteria object that defines the relationship and this will be used to load the related object.
 /// </summary>
 /// <typeparam name="T">The type of the business object to load</typeparam>
 /// <param name="relationship">The relationship to use to load the object</param>
 /// <returns>An object of type T if one was found, otherwise null</returns>
 public T GetRelatedBusinessObject <T>(SingleRelationship <T> relationship) where T : class, IBusinessObject, new()
 {
     return(GetBusinessObject <T>(Criteria.FromRelationship(relationship)));
 }