Question

What I want to do

I want to cross-reference index columns of .NET4.0 DataTables. My use case is that I have a table with data using temporary primary keys. These keys are referenced in other tables. Here is an example:

     Reference Table with temporary ids
     ╔════╦════════════╗
     ║ id ║ Name       ║
     ╠════╬════════════╣
     ║ -1 ║ Blubb      ║
     ║ -3 ║ Bla        ║
     ║ -7 ║ Plisch     ║
     ╚════╩════════════╝
       ^
╔════╦════════╦═════════════╗
║ id ║ ref_id ║ Name        ║
╠════╬════════╬═════════════╣
║  1 ║ -1     ║ Refs Blubb  ║
║  2 ║ -3     ║ Refs Bla    ║
║  3 ║ -7     ║ Refs Plisch ║
╚════╩════════╩═════════════╝

I want to be able to change the temporary ids of the reference table into real DB ids in this one table only and have the other ids change automagically. So after changing one id in the reference table it should look like this.

     Reference Table with one valid and two temporary ids
     ╔════╦════════════╗
     ║ id ║ Name       ║
     ╠════╬════════════╣
     ║ 42 ║ Blubb      ║ <- -1 changed to 42 (bubbles up to depending tables)
     ║ -3 ║ Bla        ║
     ║ -7 ║ Plisch     ║
     ╚════╩════════════╝
       ^
╔════╦════════╦═════════════╗
║ id ║ ref_id ║ Name        ║
╠════╬════════╬═════════════╣
║  1 ║ 42     ║ Refs Blubb  ║
║  2 ║ -3     ║ Refs Bla    ║
║  3 ║ -7     ║ Refs Plisch ║
╚════╩════════╩═════════════╝

I know how I would do this manually but maybe there is a way to fit this behavior into a dataset constraint, so I don't have to invent the wheel once more :-)

Any help would be appreciated, thanks!

Was it helpful?

Solution

I'm closing this now, there seems to be no such thing that is built into the framework.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top