我正在尝试使用
来获取最大值,最小值和均值context.SystemUser
.Include(x => x.Stores)
.ThenInclude(a => a.StoreStockDetail)
.Where(b => b.UserName == userName)
.Select(c => new
{
/*max, min, mean values of columns of StoreStockDetail*/
});
public class SystemUser
{
public int Id { get; set; }
public virtual List<Store> Stores { get; set; }
public SystemUser()
{
this.Stores = new List<Store>();
}
}
public class Store
{
public int Id { get; set; }
public virtual StoreStockDetail StoreStockDetail { get; set; }
}
public class StoreStockDetail
{
public int Id { get; set; }
public int BackStore { get; set; }
public int FrontStore { get; set; }
public int ShoppingWindow { get; set; }}
public int StoreId { get; set; }
public virtual Store Store { get; set; }
}
我需要具有BackStore,FrontStore和ShoppingWindow列的最大值,最小值和均值报告。
谢谢
答案 0 :(得分:0)
代替使用一系列LINQ表达式,您可以先展平SystemUser中的商店列表,然后使用结果查找最大值,最小值和平均值。试试这个:
[[2,3,6],[1,5,9],[4,8,12],[7,10,11]]