Scenario:
I have a lookup table: Customer with PrimaryKey CustomerName
I want the ability to "clean up" an incorrect spelling of a CustomerName, for example:
Joe Smmmith UPDATE TO Joe Smith
NOTE: Joe Smith already exists in the Customer table!!!
So, since this is the primary key and the new value already exists, I need to first update all rows in all descendant table to the new value, and then delete the original row.
So in this case, I was hoping to be able do something like
Dim customer as New CustomerEntity("Joe Smmmith")
For each relation as IRelation in customer.Relations
'And then in here (but only for child relations), for each relation, we would have to
'perform an UpdateMulti with the appropriate filter.
'In this case, the appropriate filter is (CustomerFields.CustomerName = "Joe Smmmith"), BUT, I don't want to hardcode this, I want to be able to properly derive this purely based on the "metadata" that is hopefully available through the relations collection.
Next
So....
a) Do you understand what I mean? Basically, perform and update on all tables subordinate to Customer, updating the appropriate column in the subordinate table from "oldValue" to newValue
b) Is it possible, and if so, could you maybe show a little pseudocode to point me in the right direction?
(And yes, I can also think of scenarios that are more complicated, ie: if the relation has > 1 column involved, but lets not worry about that for now, that hopefully will be a simple enhancement).
The reason I want to do this is, I want one nice generic piece of code that can handle this fix on all lookup tables, so I will implement it on one form, and pass the relevant information of what I am updating to this for, from the respective lookup table maintenance form. And as the system grows, this functionality will just continue to work for everything.