Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way how to achieve this <em>(one of many, because you can also use some fully-typed filter object etc or some query builder)</em> could be like this draft:</p> <p>Part one and two:</p> <pre><code>// I. a reference to our query var query = session.QueryOver&lt;Event&gt;(() =&gt; @eventAlias); // II. join, filter... whatever needed query .Fetch(@event =&gt; @event.FiscalYear).Eager var joinQuery = query .JoinQueryOver(...) .Where(() =&gt; !@eventAlias.IsDeleted) ... </code></pre> <p>Part three:</p> <pre><code>// III. Order BY // Assume we have a list of strings (passed from a UI client) // here represented by these two values var sortBy = new List&lt;string&gt; {"Name", "CodeDesc"}; // first, have a reference for the OrderBuilder IQueryOverOrderBuilder&lt;Event, Event&gt; order = null; // iterate the list foreach (var sortProperty in sortBy) { // use Desc or Asc? var useDesc = sortProperty.EndsWith("Desc"); // Clean the property name var name = useDesc ? sortProperty.Remove(sortProperty.Length - 4, 4) : sortProperty; // Build the ORDER order = order == null ? query.OrderBy(Projections.Property(name)) : query.ThenBy(Projections.Property(name)) ; // use DESC or ASC query = useDesc ? order.Desc : order.Asc; } </code></pre> <p>Finally the results:</p> <pre><code>// IV. back to query... call the DB and get the result IList&lt;Event&gt; s = query .List&lt;Event&gt;(); </code></pre> <p>This draft is ready to do sorting on top of the root query. You can also extend that to be able to add some order statements to <code>joinQuery</code> (e.g. if the string is "FiscalYear.MonthDesc"). The logic would be similar, but built around the joinQuery (see at the part one)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload