I have a problem when I run a query that have "group by" in it.
I have the following code :
Code: Select all
var horairesByDate = from item in ((App)Application.Current).db.Horaires
where item.Complete == false && item.Datefin >= startDate.Date && item.Datedebut < endDate.Date
orderby item.Datedebut
group item by item.Datedebut.Date
into groupedByDate
select groupedByDate;
var myList = await horairesByDate.ToListAsync();
// var myList = await horairesByDate.ToListAsync();
foreach (var List in myList)
{
var currentList = List;
foreach (var horaire in currentList)
{
System.Diagnostics.Debug.WriteLine(horaire.Datedebut.ToString() + " " + horaire.Datefin.ToString() + " ID : " + horaire.Id + " Evénement : " + horaire.Evenement);
}
}
GroupedItems.Source = horairesByDate;
I have also the same query without grouping :
Code: Select all
((App)Application.Current).db = new TtvDevV1DataContext()
bool exist = ((App)Application.Current).db.DatabaseExists();
var query = from item in ((App)Application.Current).db.Horaires
where item.Complete == false && item.Datefin >= dateDebut && item.Datedebut < dateFin
orderby item.Datedebut
select item;
var currentList = await query.ToListAsync();
foreach (var horaire in currentList)
{
System.Diagnostics.Debug.WriteLine(horaire.Datedebut.ToString() + " " + horaire.Datefin.ToString() + " ID : " + horaire.Id + " Evénement : " + horaire.Evenement);
}
ItemGridView.ItemsSource = currentList;
I would like to know if you have any idea why I get this problem.
Thank you in advance!