Load project options using API library
kkchan
Posts: 33
Hi,
Just to double confirm that, If I have set all the replication option and save it. Can I use SQL toolkit C# library to load the settings from project file so that I don't have to hardcode inside my application?
Just to double confirm that, If I have set all the replication option and save it. Can I use SQL toolkit C# library to load the settings from project file so that I don't have to hardcode inside my application?
Comments
HTH
Project Manager
Red Gate Software Ltd
When I suck in a project file, the resulting comparison does not have any regard for the tables and and views and column filters that i have set in the project configuration - whether the project.RepayUserActions is used or not.
Please see a related article...
http://www.red-gate.com/MessageBoard/vi ... seractions
Project Manager
Red Gate Software Ltd
I have seen the reference and applied the function call you refer to in this manner:
using (ComparisonSession session = new ComparisonSession())
{
// Create the mappings between the two db
SchemaMappings mappings = new SchemaMappings();
project.ReplayUserActions(ref mappings);
// TODo 20080328 -- this is wierd !! http://www.red-gate.com/MessageBoard/vi ... seractions
mappings.Options = project2.Options;
mappings.CreateMappings(db1, db2);
session.CompareDatabases(db1, db2, mappings);
Console.WriteLine("Comparison run");
etc.
HTH
Project Manager
Red Gate Software Ltd
also you picked up on project vs project2
Unfortunately the following loop :
foreach (TableMapping mapping in mappings.TableMappings) ...
still wants to use every table in the database - rather than just the ones in the project configuration.
Thanks
Jimboh
//Should check if this is true
LiveDatabaseSource liveDb = project2.DataSource1 as LiveDatabaseSource;
db1.RegisterForDataCompare(liveDb.ToConnectionProperties(), Options.Default);
//Should check if this is true
liveDb = project2.DataSource2 as LiveDatabaseSource;
db2.RegisterForDataCompare(liveDb.ToConnectionProperties(), Options.Default);
is there some thing more that should be done first ?
If you yourself are looping through mappings.TableMappings you'll need to pay attention to the .Include property.
Getting there I hope.
Project Manager
Red Gate Software Ltd
Please don't keep me in suspense. where and how do we use .Include and what object is it referring to ?
Jimboh
If you're using the TableMappings you'll need something like...
Not sure what more you're after here?
Project Manager
Red Gate Software Ltd
I think we are there. The use of mapping.Include property in the manner as you suggest, provides the necessary filter.
The API documentation could certainly be a bit more forthcoming in how this property is applied.
Ultimately, in this current exercise, I am trying to do an Export - similar to SQLDataCompare export - except I only want the left side and no duplicate columns in the CSV/xml file. This is mainly to get Static data for version control -- the aspect that is missing from SQL Compare scripting.
It must be getting close to close of business time in Cambridge and I thank you for your care and attention.
Until next time,
Jimboh
Project Manager
Red Gate Software Ltd