none
DataColumn Expression Aggregate Function with Filtering RRS feed

  • Question

  •  

    I have a DataSet with two DataTables.  The second DataTable is a child of the first parent DataTable via a DataRelation.  I want to have a DataColumn in the parent DataTable that uses an aggregation function like Count, but I only want to count rows in the child table that meet a certain filtering criteria.  An example of what I want is something like:

     

    Count(Child([ChildTable]).[ColumnToTest] = 'Value To Test For')

     

    When this expression is evaluated I get the following error message:

     

    "Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier."

     

    In a Sql Query I would use something like:

     

    SELECT Count(*) AS MyResult FROM ChildTable WHERE ColumnToTest LIKE '%Value To Test For%' GROUP BY ParentID

     

    Does anyone have any suggestions about how to do what I want do?

     

    Thanks in advance.

    Sunday, November 16, 2008 3:01 PM