[英]Total count of items in child collections in .NET
How to get count of items in the child collection ?如何获取子集合中的项目数?
class company
{
public ObservableCollection<employee> employees { get; set; }
}
class employee
{
}
Lets say there are 5 companies and each company has 7 employees in its collection.假设有 5 家公司,每家公司都有 7 名员工。 How to get the count of total employees (=35)?
如何获得员工总数(= 35)?
您可以使用SelectMany
Companies.SelectMany(x => x.employees).Count()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.