Typed Dataset column backed by file (not unlike SQL Server Filestream column) RRS feed

  • Question

  • Hi,

    We hold all of the data for our application's "documents" in typed datasets.  We are now adding the ability to "attach" files (that could be huge) to our "documents".  Ideally these attachments would just be held in another typed dataset, like all the rest of our data.  HOWEVER, to avoid memory issues (particularly LOH issues), we do NOT want to load those potentially-huge files into memory.

    So, my ideal implementation would be a typed dataset where the "ZippedFile" column was implemented as a file-backed column.

    I could implement that this way:

    (1)  The ZippedFile column would be of type string, where in-memory that string was the local pathname to the file on disk

    (2)  When I serialize the dataset to XML, the ZippedFile column would NOT write that local pathname... instead it would read the file and stream its base64-encoded contents into that field... as if the base64-encoded string had been in that field all the time

    (3)  When I deserialize the dataset from XML, the ZippedFile column would NOT stream all that into a giant string in memory... instead it would create a temp file, put the path for that temp file into the string in memory, and then stream the un-base64-encoded contents from the XML into a that temp file.

    (4)  When the typed DataSet gets Disposed, it will release the temp file.

    Unfortunately, it is not clear to me how I can override the XML serialization of a typed dataset to implement that behavior.  The ZippedFile "column" need not be an actual column... it is fine for is to be a Property of the partial class of that typed DataSet, if that is more easily implemented.

    Suggestions on how to do this?

    ( With the addition of Filestream attributes to SQL Server columns, I was hopeful there would be a parallel implemented in ADO Datasets... but I don't see that... it seems there is no expectation to use ADO Datasets with SQL data tables with Filestream columns... but maybe I just haven't found the right documentation. )

    Any guidance would be greatly appreciated!

    Wednesday, July 30, 2014 10:59 AM


  • Hello,

    >> Unfortunately, it is not clear to me how I can override the XML serialization of a typed dataset to implement that behavior. 

    By default serialization, this is impossible. Given a type that we cannot directly control serialization of at the class level, you could create a proxy type to manually process the serialization/deserialization process of the target type, for details, please check this link:



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Thursday, August 7, 2014 6:40 AM
    Thursday, July 31, 2014 3:29 AM