We would like one of our project to support various databases (MySql and Oracle to begin with) "out of the box".
Reading through the forums, it looks like this should be done by using one common DbGeneric, and multiple dedicated DbSpecifics. We have troubles generating that common DbGeneric.
By carefully setting up the databases (fields order, fields types...) we can generate almost identical DbGenerics. Only the FieldInfoProvider classes differ, more precisely the values of base.AddElementFieldInfo() maxLength, scale and precision parameters.
E.g. for an Int32 field we have
- In MySql : int => 0, 0, 11
- In Oracle : NUMBER(9,0) => 22, 0, 9
For a boolean field we have
- In MySql : tinyint(1) => 0, 0, 1
- In Oracle : NUMBER(1,0) => 22, 0, 1
For a "text" field we have
- In MySql : text => length is 65535
- In Oracle : NCLOB => length is ... much bigger
Text fields are a good example because, no matter how much you tweak the database field definitions, it may very well be the case that database A and database B simply don't have matching max lengths.
So... we're a bit lost here. The only idea we have is to move bits of FieldInfoProvider back to DbSpecifics and somehow inject those bits back in DbGeneric... or to just plainly ignore the differences and pick one DbGeneric at random (no idea what would happen) or...
What do you think?