显示来自多个分支的组合项目数量 [英] Display combined item quantity from multiple branches
本文介绍了显示来自多个分支的组合项目数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I hit a stumbling block and cannot break through. When I add a product it can be at both branches, if for example theres 2. Now the problem arises when I want to display a product on the store front. How do I display just one of the duplicate product but the quantity to be combined from both branches and displayed
我有什么试过:
What I have tried:
I have a table
public class Branch
{
public int Id{get;set;}
public string BranchName{get;set;}
}
public class product
{
public int Id {get;set;}
public string Name{get;set;}
public int qty {get;set}
[ForeignKey("Branch")]
public int BranchId {get;set;}
public string branchname{get;set;}
public Branch Branch {get;set;}
}
推荐答案
通过Id(或名称,如果唯一)和Sumqty查询product:
Enumerable.Sum方法(System.Linq)| Microsoft Docs [ ^ ]
Query "product" by "Id" (or name, if unique) and "Sum" "qty":
Enumerable.Sum Method (System.Linq) | Microsoft Docs[^]
这篇关于显示来自多个分支的组合项目数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文