通过选择Linq组的特定列 [英] Select specific columns for Linq group by
本文介绍了通过选择Linq组的特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个嵌套的ListView。有点儿像这样的:点击
http://mattberseth.com/blog
var query =(from c in context.customer_order
where c.id> 8000
c组名c到cgroup
select new {cgroup.Key ,Orders = cgroup});
我只想将几个特定的列加载到cgroup项目中。
就像您通常在SQL中使用select语句一样。
这可能吗?我有一个blob在表中,它需要年龄加载,如果它被包括。
解决方案
var query =(from c from context.customer_order
where c.id> 8000
group c by c.person_id into cgroup
select new {cgroup.Key,Orders = $ b $ c from cgroup中的项目
选择new {item.Foo,item.Bar}
});
I have a nested ListView. Kinda like this one:
http://mattberseth.com/blog/2008/01/building_a_grouping_grid_with.html
And the following Linq query:
var query = (from c in context.customer_order
where c.id > 8000
group c by c.person_id into cgroup
select new { cgroup.Key, Orders = cgroup });
I only want to load a few specific columns into the cgroup item. Just like you normally do with the "select" statement in SQL. Is that possible? I have a blob in the table and it takes ages to load if it is included.
解决方案
var query = (from c in context.customer_order
where c.id > 8000
group c by c.person_id into cgroup
select new { cgroup.Key, Orders =
from item in cgroup
select new { item.Foo, item.Bar }
});
这篇关于通过选择Linq组的特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文