/// <summary>
 ///     Gets the <see cref="IQuerySource" /> corresponding to the given <paramref name="node" />, throwing an
 ///     <see cref="InvalidOperationException" />
 ///     if no such clause has been registered in the given <paramref name="context" />.
 /// </summary>
 /// <param name="node">The node for which the <see cref="IQuerySource" /> should be returned.</param>
 /// <param name="context">The clause generation context.</param>
 /// <returns>The <see cref="IQuerySource" /> corresponding to <paramref name="node" />.</returns>
 public static IQuerySource GetQuerySourceForNode(IQuerySourceExpressionNode node,
                                                  ClauseGenerationContext context)
 {
     try
     {
         return((IQuerySource)context.GetContextInfo(node));
     }
     catch (KeyNotFoundException ex)
     {
         var message = string.Format(
             "Cannot retrieve an IQuerySource for the given {0}. Be sure to call Apply before calling methods that require IQuerySources, and pass in "
             + "the same QuerySourceClauseMapping to both.",
             node.GetType().Name);
         throw new InvalidOperationException(message, ex);
     }
 }