Weird composite key for Active Record

34 views
Skip to first unread message

Tony Dunsworth

unread,
Apr 13, 2012, 10:11:12 AM4/13/12
to castle-pro...@googlegroups.com
I have a feeling this has been answered before and if so, I would appreciate it if someone would link to the discussion so I can work this out.
 
I'm working on a standalone application and one of the tables I have to use (I did not create theses tables.....) consists of a composite key. Ok, no big deal, I have seen the documentation and I can make sense of it when the columns are both ints. However, one of these columns is a string (varchar2 Oracle 10g database) and that is gumming up the works in the GetHashCode() override for obvious reasons.
 
Anyone else worked around this before me and is willing to point me toward figuring it out? I would really appreciate it. If there is extra detail needed, let me know and I can supply what I can.
 
Thanks a lot in advance for any help/direction. (Not asking you to solve it for me, just show me where I need to go so I can figure it out)
 
 Cheers,
Tony Dunsworth

Tony Dunsworth

unread,
Apr 13, 2012, 4:56:31 PM4/13/12
to castle-pro...@googlegroups.com
I ended up finding a solution. Instead of
 
public override int GetHashCode()
{
    return key1 ^ key2;
}
 
I used
 
public override int GetHashCode()
{
    return key1.GetHashCode() ^ key2.GetHashCode();
}
 
and it appears to work find so far..... Haven't taken it out for much of a test drive yet, but I'm getting there.
 
T
Reply all
Reply to author
Forward
0 new messages