Selecting cols to compare and updating certain cols only
hemantgaur
Posts: 27
Hi I am new to Red Gate API, so it might sound like a basic question.
Table T1 has following columns. C1, C2, C3, C4, C5, C6.
I want to compare only C2, C3, C4 columns with destination. I want to synchronize only these columns if they have a different value and ignore C5 and C6. C1 is the primary key.
I want to do it through the API and not the interface. If you can just explain that will be fine, if you have a sample code, that would be even better.
There is some urgency, so if you can expedite it, it will be great.
Table T1 has following columns. C1, C2, C3, C4, C5, C6.
I want to compare only C2, C3, C4 columns with destination. I want to synchronize only these columns if they have a different value and ignore C5 and C6. C1 is the primary key.
I want to do it through the API and not the interface. If you can just explain that will be fine, if you have a sample code, that would be even better.
There is some urgency, so if you can expedite it, it will be great.
Comments
When you first map the tables together, all the columns will be mapped by default - e.g.
You can then exclude specific columns by setting the FieldMapping include property to 'false'.
We have an example on our website of excluding a column with a specific name from all tables in the project, but you can easily change it to exclude columns from a specific table.
You can find the example here
I hope this helps.
Thank you.
You can omit columns using the mappings in much the same way as you would omit tables, but there are also filters and Selection Delegate methods that you can use to filter the columns that will be synchronized after they had already been included in the actual comparison.
Because there are so many ways of filtering the comparison and the synchronization, I wrote a list of the merits of each method and put it on our wiki:
http://labs.red-gate.com/index.php/Filt ... a_overview
I think that the "FieldMapping.Remove" method could be the best option to use from your description.