Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ query with group by and ascending ordering not working
    primarykey
    data
    text
    <p>I have a class Ingredients which has a property <code>Items</code> of the type <code>List&lt;Ingredient&gt;</code>.<br> In one of my pages I am using a GridView to display all the ingredients, grouped by first letter:</p> <pre class="lang-xml prettyprint-override"><code>&lt;Page.Resources&gt; &lt;CollectionViewSource x:Name="IngredientsViewSource" IsSourceGrouped="True" ItemsPath="Items"/&gt; &lt;/Page.Resources&gt; </code></pre> <p>when the page is loaded, the CollectionViewSource's Source property is set like this:</p> <pre><code>this.IngredientsViewSource.Source = CurrentData.Ingredients.GroupedItems; </code></pre> <p><code>GroupedItems</code> is a property of the Ingredients class, which takes the property <code>Items</code> and orders and groups everything in order to be ready to use:</p> <pre class="lang-cs prettyprint-override"><code>public object GroupedItems { get { if (this.Items != null) { return from IngredientIteration in this.Items //orderby IngredientIteration.Name ascending group IngredientIteration by IngredientIteration.FirstLetter into IngredientGroup //orderby IngredientGroup.Key ascending select new { FirstLetter = IngredientGroup.Key, Items = IngredientGroup }; } else { return null; } } private set { } } </code></pre> <p>this is working quite well. Now I would like to sort the result, because now the first letters' order is all messed up. However, when I remove the comment marks in front of the two <code>orderby</code> clauses, it get's totally weird. Leaving the orderby clauses like it is now results in correctly ordered groups, but only the first item per group is showed.<br> When I change ascending to descending, though, everything works as expected: groups are sorted descending, all items are shown, and the items are sorted descending inside each group. </p> <p>This makes no sense to me, why is descending working but ascending not? Am I missing something here?</p>
    singulars
    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. 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