display data sorted by date

后端 未结 3 519
庸人自扰
庸人自扰 2021-01-24 10:05
public class Person
{
    public string Name {get; set;}                
    public DateTime Created { get; set; }
}

public class MyData
{
   public List          


        
3条回答
  •  隐瞒了意图╮
    2021-01-24 10:30

    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);
            }
    

提交回复
热议问题