如果项目的总和小于最小库存,如何获得项目的总和值 [英] How to get the sum value of the item if its sum quantity less than min stock
本文介绍了如果项目的总和小于最小库存,如何获得项目的总和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有两个包含此样本数据的表:
i have two table with this sample data:
items:
itemID---MinStock
------------------
1 --- 100
2 --- 5
3 --- 20
4 --- 10
stock:
id---itemID---Qnty
------------------
1 --- 1 --- 5
2 --- 2 --- 10
3 --- 3 --- 5
4 --- 4 --- 10
5 --- 1 --- 7
6 --- 1 --- 20
7 --- 2 --- 5
8 --- 3 --- 25
9 --- 2 --- 5
如果其总和数量小于MinStock(带有实体框架),如何得到该项目的总和值。
我尝试过:
i没有任何想法这样做..
how to get the sum value of the item if its sum Quantity less than MinStock (with entity framework).
What I have tried:
i don't have any idea to do it ..
推荐答案
如果我理解你很好,你不知道股票
表中Qnty
字段的总和如何...
这是这样的:
If i understand you well, you don't know how the get sum ofQnty
field instock
table...
This is the way:
var result = dbcontext.stock
.GroupBy(x=>x.itemID)
.Select(grp=>new
{
itemID = grp.Key,
Count = grp.Sum(x=>x.Qnty)
})
.ToList();
剩下的工作属于你了!
The rest of job belongs to you!
这篇关于如果项目的总和小于最小库存,如何获得项目的总和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文