我得到onlinedata,我希望在单元格中显示指定的时间,日期时间范围是9:00:00到13:00:00我希望每个5分钟从onlinedata.i获取数据不要使用switch或if-else < / p>
List<TradeDto> cMIMData = new List<TradeDto>();
cMIMData = (List<TradeDto>)data;
cMIMData具有TradeDate,TradeDateTime,TradeTime,...和值属性
答案 0 :(得分:1)
您的描述不够好,必须使用基于日期增加5分钟,您可以使用循环(while,for,...)并使用lambda表达式检查在线数据
cMIMData = cMIMData.OrderByDescending(x => x.TradeDateTime).ToList();
startDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 9, 5, 0);
endDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 13, 0, 0);
while (startDate < endDate)
{
var value = cMIMData.Where(x => x.TradeDateTime.Date == your date && x.TradeTime >= startDate.AddMinutes(-5).TimeOfDay &&
x.TradeTime <= startDate.TimeOfDay).First(); //get last item value in Limit specified time
startDate = startDate.AddMinutes(5);
}