Hi,
I've got a global in-memory table which is kind of a control table for a lot
of processes. I've added quite a few non-persisted properties to the row
objects in memory, such as collections of threads, etc., which are
dynamically populated.
Here's my basic issue. I'd like to monitor the source table in the database
and pull in new rows that might have been created in different processes. I
don't want to just re-fill the data table, because I've got all these other
objects attached to the rows.
Anyway, I tried to do this with brute force. I created a new table, filled
it with the current data, looped through the rows till I found one that
wasn't in my in-memory global control table, and then...
well, what, exactly? C# wouldn't let me just add a row from one table to the
other, and there's no row.clone method. So I added a row by calling the
generated Add method whose signature contains a parameter for each field
value. But then when I tried to update the record (with a table adapter's
Update method, using the row as parameter), I got a "duplicate key" error.
Apparently, the table adapter is trying to insert a new record instead of
updating the old.
Well, I worked around this by *deleting* the original record after copying
it's info into the in-memory table, and then calling Update inserted a new
record without a key conflict. But this seems like the ugly way around. Is
there an easier or at least less klutzy way of doing this? Thanks.
--
Warren Sirota
www.wsdesigns.com