> ## Content Index
> Fetch the complete content index at: https://blogs.remobjects.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Grouping in DA LINQ
- URL: https://blogs.remobjects.com/2011/08/05/grouping-in-da-linq/
- Published: 2011-08-05T14:41:42.000Z
- Updated: 2018-08-22T06:17:45.000Z
- Author: alexk
- Tags: #Import 2026-08-17 20:17

I would like to give you a preview of the next release of *DataAbstract for .NET*, which will provide grouping support in *DA LINQ* (and in *DA SQL* as well).  
You will be able to write queries like this:

A simple GROUP BY with an aggregate function Count:

| var q = from x in DataModule.Instance.DataAdapter.GetTable() group x by x.Client into g select new { Client = g.Key, OrderCount = g.Count() }; return q.ToList(); |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |

This query will be translated into the followig DA SQL query:

| SELECT\[t0\].\[Client\],COUNT(\*)AS\[agg1\]FROM\[Orders\]\[t0\]GROUPBY\[t0\].\[Client\] |
| --------------------------------------------------------------------------------------- |

The query in action:

[](https://blogs.remobjects.com/wp-content/uploads/2011/07/Simple-GROUP-BY-with-aggregate-function-Count.png)

A GROUP BY with other aggregate functions:

| var q = from x in DataModule.Instance.DataAdapter.GetTable() group x by x.Provider into g select new { provID = g.Key, sumVal = g.Sum(x => x.Total), minVal = g.Min(x => x.Total), maxVal = g.Max(x => x.Total), avgVal = g.Average(x => x.Total) }; return q.ToList(); |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

This query will be translated into:

| SELECT\[t0\].\[Provider\],SUM(\[t0\].\[Total\])AS\[agg1\],MIN(\[t0\].\[Total\])AS\[agg2\],MAX(\[t0\].\[Total\])AS\[agg3\], Avg(\[t0\].\[Total\])AS\[agg4\]FROM\[OrderDetails\]\[t0\]GROUPBY\[t0\].\[Provider\] |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

The query in action:

[](https://blogs.remobjects.com/wp-content/uploads/2011/07/GROUP-BY-with-other-aggregate-functions.png)

A GROUP BY on several fields:

| var q = from x in DataModule.Instance.DataAdapter.GetTable() group x by new { x.Product, x.Provider } into g select new { prodID = g.Key.Product, provID = g.Key.Provider, sumVal = g.Sum(x => x.Total) }; return q.ToList(); |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

The query will be translated into:

| SELECT\[t0\].\[Product\]AS\[prodID\],\[t0\].\[Provider\]AS\[provID\],SUM(\[t0\].\[Total\])AS\[agg1\]FROM\[OrderDetails\]\[t0\]GROUPBY\[t0\].\[Product\],\[t0\].\[Provider\] |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

The query in action: