posts - 112, comments - 174, trackbacks - 1

ThenByDescending

There are 1 entries for the tag ThenByDescending
Linq: ThenBy e ThenByDescending

Se abbiamo la necessità di ordinare una query Linq per più campi possiamo utilizzare gli operatori ThenBy e ThenByDescending. Considerando le classi del post precedente, se volessimo ordinare  la query: 1 var query1 = esamiSostenuti 2 .OrderBy(es => es.ID_Studente) 3 .Select(es => new { es.ID_Studente, es.Voto }); non solo per il campo ID_Studente, ma anche per il campo Voto, possiamo scrivere: 1 //Ordinamento Ascendente 2 var query2 = esamiSostenuti 3 .OrderBy(es => es.ID_Studente) 4 .ThenBy(es => es.Voto) ...

posted @ venerdì 16 maggio 2008 8.49 | Feedback (0) | Filed Under [ LINQ ]

Powered by: