Conflicts between databases

31 views Asked by At

I have an automation project that I use for several similar sites. The databases of the sites are also similar beside the USERS table.

In one database the table USERS has the column Fname, in the other one this column is not present. In the other database I have a column named RegesrationDate and in others this column is not present. etc. etc.

When I am running a query I get the error

specified cast is not valid.

because I can't cast the return value (which has more columns then I am holding in my dbml file).

There is a way in my project to make a generic dbml object that I will run:

SELECT * FROM USERS

and to get a normal object. Do you have other ideas how to make my project work?

1

There are 1 answers

0
tokenaizer On BEST ANSWER

first approach:

My suggestion is to remove all unique fields and get the generic table at first. After that, use db.ExecuteQuery for the unique fields every special db.

second: It's not generic db, therefore use two (or more) user table on your dbml file.

userDb1 table, userDb2 table....

in c# do:

    if(dbname == 1){
        var a =db.userdb1.select()....
    }