我正在尝试将我的数据库结果添加到列表中。这是我的班级:
var myList = new List<MyClass>();
foreach (var element in compsList)
{
myList.Add(Price_tbl
.Where(p => p.Ticker.Equals(element.Tick) && p.Tick_datetime <= DateTime.Today)
.GroupBy(p => new { Comp = p.Ticker })
.Select(p => new MyClass {
Tick = p.Key.Comp,
Exchange = element.Exchange,
Price = p.OrderByDescending(c => c.Tick_datetime).Select(c => c.Close_price).FirstOrDefault(),
Volume = (p.Sum(c => c.Volume) / 52),
}));
}
这是我的惯例:
cannot convert from 'System.Linq.IQueryable<UserQuery.MyClass>' to 'UserQuery.MyClass'
但是我收到了错误:
var progress = document.getElementById('progress');
var bufferBar = document.getElementById('buffer');
var divID = document.getElementById('c-markers');
for (var i = 0; i < 3; i++) {
var anchor = document.createElement('a');
anchor.id = "marker" + i;
divID.appendChild(anchor);
var marker = document.getElementById("marker" + i);
marker.style.backgroundImage = "url('http://i.imgur.com/YTWgnzn.png')";
marker.style.left = (i * 150) + 'px';
progress.value = .33;
bufferBar.value = .66;
}
有没有其他方法可以将结果添加到列表中? (我现在几个小时都在绞尽脑汁。)