B
Brian
I know this is the wrong way to do it, but maybe someone can tell me the
right way to do it...
I have two different databases that I need to synchronize. The database
doesn't have keys exactly, but it does provide a rowid function.
So, I am storing a dictionary of <string, long>, string being the rowid
and long being a sum of the hash code for each column in the row.
With this dictionary, it is very easy to determine if a row is new, has
changed, or is already in sync with the target system:
* If I have a rowid that doesn't exist in the dictionary, then I know
it is a new row and I can call my insert code.
* If I have a rowid that exists in the dictionary, and the sum of hash
codes is the same as in my dictionary, then I know that the row has not
changed and there is no action to take.
* If I have a rowid that exists in the dictionary, and the sum of hash
codes is not the same as my dictionary, then I know the row of has
changed, and I need to call my update code.
-----
So, my question is, with this situation, how can I get the same results,
but not store GetHashCode(). I need some kind of "stable" hash
calculation. And it needs to take all kinds of objects; string, int,
decimal, double, etc.
I started to think I could just use a hash code on string and call
ToString() on each column, but this looks just as dangerous as trusting
GetHashCode() not to change.
Thanks for any tips...
Brian
right way to do it...
I have two different databases that I need to synchronize. The database
doesn't have keys exactly, but it does provide a rowid function.
So, I am storing a dictionary of <string, long>, string being the rowid
and long being a sum of the hash code for each column in the row.
With this dictionary, it is very easy to determine if a row is new, has
changed, or is already in sync with the target system:
* If I have a rowid that doesn't exist in the dictionary, then I know
it is a new row and I can call my insert code.
* If I have a rowid that exists in the dictionary, and the sum of hash
codes is the same as in my dictionary, then I know that the row has not
changed and there is no action to take.
* If I have a rowid that exists in the dictionary, and the sum of hash
codes is not the same as my dictionary, then I know the row of has
changed, and I need to call my update code.
-----
So, my question is, with this situation, how can I get the same results,
but not store GetHashCode(). I need some kind of "stable" hash
calculation. And it needs to take all kinds of objects; string, int,
decimal, double, etc.
I started to think I could just use a hash code on string and call
ToString() on each column, but this looks just as dangerous as trusting
GetHashCode() not to change.
Thanks for any tips...
Brian