按日期时间属性的对象分裂名单 [英] Splitting list of objects by DateTime property

查看:137
本文介绍了按日期时间属性的对象分裂名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立以电影院(当然这对研究只是小项目)。

I'm building a booking system for cinemas(of course it's just small project for studies).

下面是我的展示模型

public class ShowcaseModel
{
    public string objectId { get; set; }
    public string MovieId { get; set; }
    public int Auditorium { get; set; }

    public DateTime? StartDate { get; set; }
}

我要显示每天,在进度的形式。要做到这一点,我得到的所有陈列柜其中,日期时间是大于今天,放到

I want to display schedule in "per day" form. To achieve this i get all Showcases where DateTime is greater than today and put them into

List< ShowcaseModel >.

现在我不知道如何通过使用天startDate属性拆分此列表(成单独的列表)。

Now i don't know how to split this list(into separate lists) by day using StartDate property.

有没有办法实现这一目标?

Is there any way to achieve this?

先谢谢了。

推荐答案

您可以使用的 GROUPBY 方式:

List<ShowcaseModel> list = new List<ShowcaseModel>();
//...
var gooupByDay = list.GroupBy(o=>o.StartDate.Value.Date);

这篇关于按日期时间属性的对象分裂名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆