I have a datatable with multiple key columns (key1, key2, ..., keyN). I want to count the distinct key combinations in the table, that match a certain criteria (IsInError = false).
Basically i want to perform the query
SELECT COUNT(*) FROM (SELECT DISTINCT key1, key2, ..., keyN FROM TABLE WHERE IsInError = 'false') A
on the datatable.
I have researched a little and found that for a table containing only one key (and with no 'where') I can do this
DataTable table = new DataTable();
int nRows = table
.AsEnumerable()
.Select(r => r.Field<string>("key1"))
.Distinct()
.Count();
But how would I go about doing it with multiple keys and a condition?