我有以下型号,请参见图片。
我在弄清楚如何从汽车上获得所有类型的SUV并进行价值求和时遇到问题。
我尝试过
HelpWithSUVSUM = g.OfType<CarsSUV>()
.Where(d => d.HasPremium == true && (d.Status == "Sold").Sum(d => d.CarValue)
但是它引发了一个错误。任何帮助将不胜感激!
var statsModel = (
from c in db.Cars
join s in db.Salesman on c.SalesmanId equals c.ID into sales
select new { s, sales }
into data
group data by new { data.c.ModelName, data.c.Year } into g
select new MyData
{
CarYear = g.Key.Year,
SomeCount = g.Count(d => (d.c.Status == "Sold"),
// etc.. a few more counts
// NOW I need to get all Cars that are SUV and HasPremium and do a Sum the SUV value
HelpWithSUVSum = ....
}
).ToList();