Is there a relatively easy way to extract a relationship-consistent subset of a DataSet? The subset I want is: the rows I'm interested in, all the child and parent rows required by those rows, and nothing else.
I have around a dozen tables, each with two to four relationships to other tables.
I figure I could write code to traverse the data tables and relationships given a day or two, but I'd prefer to re-use existing code and spend that day or two on my product.
Background:
I have a strongly typed DataSet
pulled from a database of the components my company sells.
I'm considering another strongly-typed DataSet to store proposed solutions. There'll be one row per item on the Bill of Materials (BOM). Each row will describe the component's configuration.
I don't want to put solution tables in the component DataSet.
When I serialize the solution DataSet via WriteXml
, I'd like to persist just enough information about the components. If I'm storing primary keys from the component tables, that shouldn't be too hard.
It occurs to me that persisted solutions could survive expiry of data from the main component DataSet if I also persisted the appropriate rows from that DataSet. I don't want to persist the whole component DataSet, though, hence my question about extracting a useful subset.