【发布时间】:2014-11-18 01:49:25
【问题描述】:
我仍在尝试获取 LINQ,并且想知道是否有人可以阐明我在这里做错了什么。我正在从数据库中提取一堆行,并按 ManufacturerSKU 分组(ManufacturerSKU 有多个具有不同 ListingPrice 的行,我从数据库中获取具有最便宜的 ListingPrice 的 ManufacturerSKU)
//store the cheapest row for a ManufacturerSKU in a list
var product_result = (
from row in dtProductListings.AsEnumerable()
group row by row.Field<string>("ManufacturerSKU") into g
select new Product
{
ManufacturerSKU = g.Key,
ListingPrice = g.Min(x => x.Field<double>("ListingPrice")),
Manufacturer = g.Min(z => z.Field<string>("Manufacturer")),
}).ToList();
无论如何,我一直在尝试在查询中添加 where 子句,这样我就可以使用 mysql 数据库中的“TimeStamp”列在某个日期范围内获得结果。我试过添加
where row.Field< what data type even goes in here for a date time? >("TimeStamp") >= etc..
但我知道我一定做错了什么,因为它告诉我行在这种情况下不存在。我尝试在 group 子句之前添加 where 子句,在 select 之后但没有任何成功。请问有大神可以给点建议吗?
(编辑:TimeStamp 是一个日期时间)
【问题讨论】: