【发布时间】:2018-05-28 21:29:39
【问题描述】:
如何选择按月分组的行。
所以我有一个实体:
public class Security
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Quatation { get; set; }
public SecurityType SecurityType { get; set; }
public double Denomination { get; set; }
public CurrencyType DemoniationType { get; set; }
public virtual ICollection<ReportPeriod> ReportPeriods { get; set; }
}
报告期实体:
public class ReportPeriod
{
public Guid Id { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public Guid SecurityId { get; set; }
public Guid StockExchangeId { get; set; }
public double Amount { get; set; }
public virtual Security Security { get; set; }
}
因此,我需要以某种方式获取 ReportPeriod 一年中每个月的一般金额。有没有人有一些想法如何做到这一点?
【问题讨论】:
-
Start和End属性是否分别表示月份的开始日期和月份的结束日期(如 2018-01-01 00:00:00 和 2018-01-31 23:59:59 )? -
@user1672994 不,例如可以是 2-3 天的范围。不知何故,我需要像一月份那样收集:***金额
-
@Jorge 的开始和结束范围可以跨月吗?
-
懒惰(技术上不正确)的替代方案可能是按两个日期的平均值(如果它们相隔几天)按月分组