我正在使用LINQ来选择:
double views = Counts.btnCountViewsList
.Select(x => x.Views)
.DefaultIfEmpty(0).Average();
double btnCount = Counts.btnCountViewsList
.Select(x => x.BtnCount)
.DefaultIfEmpty(0).Average();
但是我想知道这可以用一个查询并选择这个对象吗?
public class BtnCountViews
{
public BtnCountViews()
{
}
public int DayOfYear { get; set; }
public int Month { get; set; }
public int Year { get; set; }. // <<<<<<
public double BtnCount { get; set; } // <<<<<<
public double Views { get; set; }
}
答案 0 :(得分:0)
就这么简单。这只是一个指导原则。我希望你能根据自己的需要进行调整。
Counts.btnCountViewsList.Select(x => new BtnCountViews()
{
BtnCount = 0,
DayOfYear = 0,
Month = 0,
Views = 0,
Year = 0
});