获取所有实体的计数 [英] Get count for all entities

查看:79
本文介绍了获取所有实体的计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





正在使用计数工作在树视图上。

基于我的搜索输入是具有子实体的returing实体,所以需要对实体中的记录进行计数。

例如主要实体是树下的树我有芒果树和Orang树,所以看起来像我的所有孩子的计数得数我的树应该是



主要实体

| ---树(400)

........ | ------ MangoEntity(150)

........ | ------ OrangeEntity(250)

Hi,

Am working on treeview with counts.
Based on my search input am returing entity which having child entities, so need count of records in the entity.
for example Main entity is "Tree" under tree i have mango tree and Orang tree, so am looking like get counts of all my child entites count my tree should be

Main Entity
|---Tree (400)
........|------MangoEntity (150)
........|------OrangeEntity(250)

推荐答案

这应该是一个简单的计数:







This should just be a simple count:



var myEnumerable = [new {id=1,arr=[1,2,3,4]},new {2,[1,2,3]},new {3,[1,2,3,4,5,6]}];

var countedFlat = myEnumerable.Select(a=>new {a.id,count = a.arr.Count()});

foreach(var anon in countedFlat)
{
  Console.WriteLine("id:{0} - count:{1}",anon.id,anon.count);
}





输出



output

id:1 - count:4
id:2 - count:3
id:3 - count:6


这篇关于获取所有实体的计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆