在ADO.NET集合函数与GROUP BY功能 [英] Aggregate functions in ADO.NET with GROUP BY functionality
问题描述
这是一个更直接的问题,从早期的<一个词干href="http://stackoverflow.com/questions/828356/allowing-a-user-to-create-a-custom-query-of-a-table/">more一般问题,我早些时候曾现在,我已经花更多的时间寻找到ADO.NET
This is a more direct question stemming from an earlier more general question i had earlier now that I've spend more time looking into ADO.NET
我要带一个ADO.NET数据表,并执行与聚合函数(如SUM)在某些列,和A组SQL SELECT查询的等值集其余列。那么我想利用的结果,并在DataGrid中显示出来。
I want to take an ADO.NET DataTable and perform the equivalent of a SQL SELECT query with aggregate functions (such as SUM) on some columns, and GROUP BY set for the remaining columns. I then want to take the result and display it in a DataGrid.
我知道我可以创建一个包含过滤条件,集合函数的数据表的数据视图。但是, MSDN页面上的防爆pressions 说
I understand that I can create a DataView of a DataTable that contains filter criteria and aggregate functions. But the MSDN page on Expressions say that
如果你使用单个表创建聚合,就没有基的由功能性。相反,所有的行会显示在该列的值相同。的
我如何得到GROUP BY型的功能了ADO.NET没有写我的表到一个单独的数据库,并运行一个查询呢?是否有某种方式通过创建或使用第二个表办呢?
How do I get GROUP BY type functionality out of ADO.NET without writing my Table to a separate database and running a query there? Is there some way to do it by creating or using a second table?
推荐答案
您可以使用LINQ来完成这个分组的能力。此外,您还可以绑定一个DataGrid到LINQ查询,但该数据将是只读的。
You can use the grouping ability of LINQ to accomplish this. Also, you can bind a DataGrid to a LINQ query, but the data will be read only.
一个在网上搜索LINQ的分组应该让你你要去的地方。
A web search for LINQ grouping should get you where you're going.
这篇关于在ADO.NET集合函数与GROUP BY功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!