StrataFrame Forum

Relating on non primary key

http://forum.strataframe.net/Topic28753.aspx

By Ian Johnston - 10/20/2010

I am importing lagacy data. I have imported the data using sqlBulkCopy the old data priamry key is a random number entered by the user so they are all over the place. The new tables auto generate the primary keys. I heed to link te two tables on a field containing the old primary key so that I can update the FK with the new PK. I have been looking at the BusinessLayerLinkManager but am not getting anywhere. Is that the way I should be doing this?
By Ivan George Borges - 10/20/2010

Hi Ian.

If I understand what you need, you have a Parent and a Child imported from a legacy database and want to update the Child foreign key with the new Parent PK, is that so? I guess you have the value of the old Parent "primary key" stored in some field in your table, so you could create a Fill Method on your Child table that woud take the Parent table old "primary key" as a parameter and then write the SQL Server statement to fill your Child BO with that(those) record(s) and then change any field contents you would like.
By Greg McGuffey - 10/20/2010

Ian, is this a data migration task (i.e. you're doing it or writing a script to handle it one time) or is this something the users need to do as part of normal use of the app?
By Ian Johnston - 10/21/2010

Thanks for the input, got it working  using  a lookup on th old key and returning the new one.
By Ian Johnston - 10/21/2010

This is a one time migration operation. Got it working using Ivan's suggestion.
By Ivan George Borges - 10/21/2010

Glad it helped, Ian. Cool