| Author |
Message |
kkchan
Joined: 01 Dec 2007 Posts: 23
|
Posted: Sat Dec 01, 2007 11:06 am Post subject: Load project options using API library |
|
|
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? |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Mon Dec 03, 2007 9:37 am Post subject: |
|
|
If you are talking about SQL Data Compare version 6 then yes. You will have to call the function Project.ReplayUserActions() for your SchemaMappings.
HTH _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
jimboh
Joined: 29 Jan 2007 Posts: 17 Location: Melbourne Australia
|
Posted: Fri Mar 28, 2008 2:11 pm Post subject: |
|
|
Please provide more DETAIL information as to how this is used .
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. |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
|
| Back to top |
|
 |
jimboh
Joined: 29 Jan 2007 Posts: 17 Location: Melbourne Australia
|
Posted: Fri Mar 28, 2008 3:35 pm Post subject: |
|
|
Sorry for the unnecessary emphasis.
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/viewtopic.php?t=6236&highlight=replayuseractions
mappings.Options = project2.Options;
mappings.CreateMappings(db1, db2);
session.CompareDatabases(db1, db2, mappings);
Console.WriteLine("Comparison run");
etc. |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Fri Mar 28, 2008 3:56 pm Post subject: |
|
|
OK I can see what's going on there. What you're after is creating the mappings *then* applying the user actions and you're ready to roll...
| Code: |
using (ComparisonSession session = new ComparisonSession())
{
// Create the mappings between the two db
SchemaMappings mappings = new SchemaMappings();
mappings.Options = project2.Options;
mappings.CreateMappings(db1, db2);
project.ReplayUserActions(ref mappings);
session.CompareDatabases(db1, db2, mappings);
Console.WriteLine("Comparison run");
|
HTH _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
jimboh
Joined: 29 Jan 2007 Posts: 17 Location: Melbourne Australia
|
Posted: Fri Mar 28, 2008 4:06 pm Post subject: |
|
|
I like your style .. I'm actually smoking arolly right now.
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 |
|
| Back to top |
|
 |
jimboh
Joined: 29 Jan 2007 Posts: 17 Location: Melbourne Australia
|
Posted: Fri Mar 28, 2008 4:23 pm Post subject: |
|
|
perhaps you need to see the following preliminary lines ( copied from the template)
//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 ? |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Fri Mar 28, 2008 4:58 pm Post subject: |
|
|
which would then continue (for project2)
| Code: |
SchemaMappings mappings = new SchemaMappings();
mappings.Options = project2.Options;
mappings.CreateMappings(db1, db2);
project2.ReplayUserActions(ref mappings);
session.CompareDatabases(db1, db2, mappings);
|
If you yourself are looping through mappings.TableMappings you'll need to pay attention to the .Include property.
Getting there I hope. _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
jimboh
Joined: 29 Jan 2007 Posts: 17 Location: Melbourne Australia
|
Posted: Fri Mar 28, 2008 5:09 pm Post subject: |
|
|
RichardJim
Please don't keep me in suspense. where and how do we use .Include and what object is it referring to ?
Jimboh |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Fri Mar 28, 2008 6:23 pm Post subject: |
|
|
If you're using the
| Code: |
session.CompareDatabases(db1, db2, mappings);
|
It should all work.
If you're using the TableMappings you'll need something like...
| Code: |
foreach (TableMapping mapping in mappings.TableMappings)
{
if (mapping.Include)
{
// Do your stuff whatever that may be you're not telling me much
}
else
{
// Read the license agreement to SQL Log Rescue
}
}
|
Not sure what more you're after here? _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
jimboh
Joined: 29 Jan 2007 Posts: 17 Location: Melbourne Australia
|
Posted: Fri Mar 28, 2008 6:50 pm Post subject: |
|
|
richardjim
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 |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Mon Mar 31, 2008 9:34 am Post subject: |
|
|
Happy to help. _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
|