/// <summary>
        /// Allows for Related Pages lookup using Ordering on non-MultpleDocumentQuery queries.  The given Node must be on the "left" hand side in this case for ordering.
        /// </summary>
        /// <param name="baseQuery">The Base Document Query</param>
        /// <param name="nodeGuid">The NodeGuid</param>
        /// <param name="relationshipName">Name of the relationship. If not provided documents from all relationships will be retrieved.</param>
        public static DocumentQuery <TDocument> InRelationWithOrder <TDocument>(this DocumentQuery <TDocument> baseQuery, Guid nodeGuid, string relationshipName = null) where TDocument : TreeNode, new()
        {
            // Get the RelationshipID and NodeID
            int?RelationshipNameID = GetRelationshipNameID(relationshipName);
            int?NodeID             = GetNodeID(nodeGuid);

            if (!NodeID.HasValue)
            {
                return(baseQuery);
            }

            // Add the Inner Join with proper alias formatting
            if (RelationshipNameID.HasValue)
            {
                baseQuery.Source((QuerySource s) => s.InnerJoin(new QuerySourceTable("CMS_Relationship"), new WhereCondition("NodeID = RightNodeID").WhereEquals("RelationshipNameID", RelationshipNameID.Value).WhereEquals("LeftNodeID", NodeID.Value)));
            }
            else
            {
                baseQuery.Source((QuerySource s) => s.InnerJoin(new QuerySourceTable("CMS_Relationship"), new WhereCondition("NodeID = RightNodeID").WhereEquals("LeftNodeID", NodeID.Value)));
            }

            // add the by the Relationship Order
            baseQuery.OrderBy("RelationshipOrder");

            return(baseQuery);
        }
        /// <summary>
        /// Allows for Related Pages lookup using Ordering on non-MultpleDocumentQuery queries.  The given Node must be on the "left" hand side in this case for ordering.
        /// </summary>
        /// <param name="baseQuery">The Base Document Query</param>
        /// <param name="nodeID">The NodeID</param>
        /// <param name="relationshipName">Name of the relationship. If not provided documents from all relationships will be retrieved.</param>
        public static DocumentQuery InRelationWithOrder(this DocumentQuery baseQuery, int nodeID, string relationshipName = null)
        {
            // Get the RelationshipID and NodeID
            int?RelationshipNameID = GetRelationshipNameID(relationshipName);

            // Add the Inner Join with proper alias formatting
            if (RelationshipNameID.HasValue)
            {
                baseQuery.Source((QuerySource s) => s.InnerJoin(new QuerySourceTable("CMS_Relationship"), new WhereCondition("NodeID = RightNodeID").WhereEquals("RelationshipNameID", RelationshipNameID.Value).WhereEquals("LeftNodeID", nodeID)));
            }
            else
            {
                baseQuery.Source((QuerySource s) => s.InnerJoin(new QuerySourceTable("CMS_Relationship"), new WhereCondition("NodeID = RightNodeID").WhereEquals("LeftNodeID", nodeID)));
            }

            // add the by the Relationship Order
            baseQuery.OrderBy("RelationshipOrder");

            return(baseQuery);
        }