locked
Summary Tables in a strongly typed dataset RRS feed

  • Question

  • Hi there!

    I am looking for some help in an easy way to create summary tables in a strongly-typed dataset for a particular datatable. I have a similar column structure in the parent table to the following:

    CarsDataTable:

    Make
    Model
    Year
    Amount

    I would like to make the first table like:

    CarsMakeDataTable:

    Make
    Amount

    With Amount being the sum of each Makes in the table.

    CarsMakeModelDataTable:

    Make
    Model
    Amount

    With amount being the sum of each distinct make and model in the table.


    I am wondering if it is possible to achieve this using Relations and Expressions. I tried a few things, but nothing seemed to work. I am trying to cut down on stored procedures and calls respectively, so making new stored procs for each level is unacceptable. Also, I would like to avoid using code to generate the amounts using DataViews and such (since the functionality in strongly-typed datasets seems to still be restricted... boo).

    Thanks!

    Greg Reese




    Tuesday, February 16, 2010 4:00 PM

Answers

  • Relations:

    CarsMake_Cars on Make
    CarsMakeModel_Cars on Make and Model

    Amount in CarsMake and CarsMakeModel : Expression = "Sum(Child.Amount)"

    Fill the Make field of CarsMake.
    Fill the Make and Model fields of CarsMakeModel.
    Fill the Cars table.
    • Marked as answer by Harry Zhu Wednesday, February 24, 2010 4:45 AM
    Sunday, February 21, 2010 6:15 AM

All replies

  • Is this data static on the client or is it writeable?  Any reason why you could not have one stored procedure that returns all of this data to you in in one call?  It would be quicker for this to be calculated using SQL.


    Mike Huguet
    http://www.geekswithblogs.com/mikehuguet
    http://twitter.com/mhuguet
    Saturday, February 20, 2010 11:04 PM
  • I wouldn't recommend really using Strongly Typed DataSets as they are more difficult to maintain. I do realize that it is a preference, but it can potentially become a nightmare if requirements change.
    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    Sunday, February 21, 2010 1:17 AM
  • Relations:

    CarsMake_Cars on Make
    CarsMakeModel_Cars on Make and Model

    Amount in CarsMake and CarsMakeModel : Expression = "Sum(Child.Amount)"

    Fill the Make field of CarsMake.
    Fill the Make and Model fields of CarsMakeModel.
    Fill the Cars table.
    • Marked as answer by Harry Zhu Wednesday, February 24, 2010 4:45 AM
    Sunday, February 21, 2010 6:15 AM