Dynamically converting SQL to Oracle in a SQL BaseBO


Author
Message
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I have a BaseBO and want to insert logic to dynamically handle Oracle. I have looked at the code generated for Oracle BO's and see the differences. Can anyone give me advice on this in terms of what methods in my base bo I would need to override? IE... FILL a table, Insert, Delete, Update and SAVE. I am on a project that has 350 BOs in SQL and inherit from a Base BO.

Below is some code I started playing around with in my base bo. Any guidance would be helpful.

public enum DatabaseType : int

{

SQLServer = 0,

Oracle = 1

}

private static DatabaseType _DatabaseQueryType = DatabaseType.SQLServer ;



public static DatabaseType DatabaseQueryType

{

get { return _DatabaseQueryType; }



set { _DatabaseQueryType = value; }

}

private OracleCommand ConvertSqlToOracleCommand(SqlCommand cmd)

{

System.Data.OracleClient.

OracleCommand strOr = null;



return strOr;



//-- Convert the SqlCommand into an Oracle Command

}

//-- Override the base FillDataTable and add a test to see if the command should be converted to Oracle



public override void FillDataTable(DbCommand cmd)

{

if (TrustedVALETBaseBO.DatabaseQueryType == DatabaseType.Oracle)

cmd = ConvertSqlToOracleCommand((

SqlCommand)cmd);



Console.WriteLine("Base class Constructor");



base.FillDataTable(cmd);

}



//private DbCommand MassageCommand(System.Data.Common.DbCommand Command)



//{



// //-- Get a reference to the command



// SqlCommand cmd = (SqlCommand)Command;



// //-- If this business object needs to talk to Oracle, then convert the command, else, just execute it



// if (this.ShouldNativeDbTypesBeConverted)



// {



// //-- Replace the char fields before converting the command



// ///// foreach (CharEnumField field in _CharFieldsToUpdate)



// {



// ///// field.ReplaceCharFieldWithEnumField(cmd);



// }



// return this.ConvertCommand(cmd);



// }



// else



// {



// return Command;



// }



//}





///// <summary>



///// Converts the specified SqlCommand object into an equivalent OleDbCommand object.



///// </summary>



//private OleDbCommand ConvertCommand(System.Data.SqlClient.SqlCommand Command)



//{



// //-- Establish locals



// OleDbCommand loReturn = new OleDbCommand();



// Match loMatch = default(Match);



// //-- Set the basic properties on the oledb command



// loReturn.CommandText = Command.CommandText;



// loReturn.CommandType = Command.CommandType;



// //-- Update the parameters for the command



// //-- Find all of the parameters within the text & replace them



// /////loMatch = _ParameterRegex.Match(Command.CommandText);



// /////loReturn.CommandText = _ParameterRegex.Replace(Command.CommandText, "?");



// //-- Replace the matches in the text and build the parameters for the command



// while (loMatch.Success)



// {



// //-- Add the new parameter to the collection



// /////loReturn.Parameters.Add(ConvertParameter(Command.Parameters(loMatch.Value)));



// //-- Go to the next match



// loMatch = loMatch.NextMatch();



// }



// //-- Return the new command



// return loReturn;



//}


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search