kirk_bottomley
12 years agoContributor
Database Determined at Runtime
Alright, I know this must have come up before, but I swear I can't find this topic in any of my searches. I apologize if this is rehashing something already covered.
I need to compare data from SQL databases. I can create the correct data to be compared to in Stores now, while I'm writing the test, with a known SQL database. When the test is run, though, the data structure will be the same but the name of the SQL server will change every time the test is run.
I have logic to retrieve the SQL server name, but I can't find a method to compare the data with the data already in Stores. It wants to connect to the same server I stored the data with and compare the data "now" at runtime to the data I stored when writing the test.
Am I using the wrong method to compare? My idea right now is to create a second server before the test is run, write a test to compare two Stores tables, and copy the data into the second server at runtime, but that seems really inefficient. There has to be a better way.
I have a feeling I'm missing something really basic, and I'm gonna slap myself later, but I can't seem to find it.
I need to compare data from SQL databases. I can create the correct data to be compared to in Stores now, while I'm writing the test, with a known SQL database. When the test is run, though, the data structure will be the same but the name of the SQL server will change every time the test is run.
I have logic to retrieve the SQL server name, but I can't find a method to compare the data with the data already in Stores. It wants to connect to the same server I stored the data with and compare the data "now" at runtime to the data I stored when writing the test.
Am I using the wrong method to compare? My idea right now is to create a second server before the test is run, write a test to compare two Stores tables, and copy the data into the second server at runtime, but that seems really inefficient. There has to be a better way.
I have a feeling I'm missing something really basic, and I'm gonna slap myself later, but I can't seem to find it.
Hi Kirk,
You can specify new ConnectionString and update the DBTable checkpoint by using the Check method before comparing. Read the "Updating Database Checkpoints" article for details.