public class Person
{
public string Name {get; set;}
public DateTime Created { get; set; }
}
public class MyData
{
public List
You need to group the Person objects by entire days, so let's do:
var res = Model.Persons.OrderByDescending(p => p.Created)
.GroupBy(p => p.Created.ToShortDateString());
To display them on the console:
foreach(var entry in res)
{
// Day is the same for all items in a group entry.
string groupDay = entry.First().Created.ToShortDateString();
Console.WriteLine(groupDay);
// list all names of persons in that group
foreach(Person p in entry)
{
Console.WriteLine(p.Name);
}
}
I belive you would want to use groupBy so you can have the results by date :
var query = Persons.OrderByDescending(c => c.Created).GroupBy(n=> n.Created.ToShortDateString());
foreach (var d in query)
{
Console.WriteLine(d.Key);
foreach (var names in d)
Console.WriteLine(names.name);
}
you can do like:
Persons.OrderBy(p => p.CreatedDate);