Can you easily convert a DSDataResponse object to a datatable in C#

Can you easily convert a DSDataResponse object to a datatable in C# ?

The DSDataRequest is passing multiple Instrument and DataTypes objects returning to a DSDataResponse.

Thanks,

Fergal

Best Answer

  • paul.bacon
    paul.bacon LSEG
    Answer ✓

    Hi @fergal.twomey

    There is no simple means of converting from DSDataResponse to a C#
    DataTable. You would have to walk through the response collection and build the
    DataTable on the fly.

    The ProcessSnapshot method in the GetData example code produces
    tabulated output on the console. Converting that to a DataTable should be
    simple enough; simply replace the code constructing a line of tabulated output
    with code constructing a DataRow object.

    For Timeseries requests, especially with multiple instruments in each
    request, the construction would be more complex. You would want multiple
    DataTables, one for each instrument, and each row being the data for a specific
    date. The ProcessTimeSeries method in the GetData example code also produces
    tabulated data, albeit with the dates represented as columns. You would have to
    pivot that data to get the dates as rows.