EFIngresDDEXProvider/EFIngresObjectSelector.cs
/// <summary>
/// This method formats a SQL string by specifying format arguments
/// based on restrictions.  All enumerations require at least a
/// database restriction, which is specified twice with different
/// escape characters.  This is followed by each restriction in turn
/// with the quote character escaped.  Where there is no restriction,
/// a default restriction value is added to ensure the SQL statement
/// is still valid.
/// </summary>
This method formats a SQL string by specifying format arguments
based on restrictions.  All enumerations require at least a
database restriction, which is specified twice with different
escape characters.  This is followed by each restriction in turn
with the quote character escaped.  Where there is no restriction,
a default restriction value is added to ensure the SQL statement
is still valid.
This method formats a SQL string by specifying format arguments based on restrictions . All enumerations require at least a database restriction which is specified twice with different escape characters . This is followed by each restriction in turn with the quote character escaped . Where there is no restriction a default restriction value is added to ensure the SQL statement is still valid .
private static string FormatSqlString(string sql, object[] restrictions, object[] defaultRestrictions)
        {
            Debug.Assert(sql != null);
            Debug.Assert(restrictions != null);
            Debug.Assert(restrictions.Length > 0);
            Debug.Assert(restrictions[0] is string);
            Debug.Assert(defaultRestrictions != null);
            Debug.Assert(defaultRestrictions.Length >= restrictions.Length);
            object[] formatArgs = new object[defaultRestrictions.Length + 1];
            formatArgs[0] = (restrictions[0] as string).Replace("]", "]]");
            for (int i = 0; i < defaultRestrictions.Length; i++)
            {
                if (restrictions.Length > i && restrictions[i] != null)
                {
                    formatArgs[i + 1] = "N'" + restrictions[i].ToString().Replace("'", "''") + "'";
                }
                else
                {
                    formatArgs[i + 1] = defaultRestrictions[i];
                }
            }
            return String.Format(CultureInfo.CurrentCulture, sql, formatArgs);
        }
private static string FormatSqlString ( string sql , object [ ] restrictions , object [ ] defaultRestrictions ) { Debug . Assert ( sql != null ) ; Debug . Assert ( restrictions != null ) ; Debug . Assert ( restrictions . Length > 0 ) ; Debug . Assert ( restrictions [ 0 ] is string ) ; Debug . Assert ( defaultRestrictions != null ) ; Debug . Assert ( defaultRestrictions . Length >= restrictions . Length ) ; object [ ] formatArgs = new object [ defaultRestrictions . Length + 1 ] ; formatArgs [ 0 ] = ( restrictions [ 0 ] as string ) . Replace ( " " , " " ) ; for ( int i = 0 ; i < defaultRestrictions . Length ; i ++ ) { if ( restrictions . Length > i && restrictions [ i ] != null ) { formatArgs [ i + 1 ] = " " + restrictions [ i ] . ToString ( ) . Replace ( " " , " " ) + " " ; } else { formatArgs [ i + 1 ] = defaultRestrictions [ i ] ; } } return String . Format ( CultureInfo . CurrentCulture , sql , formatArgs ) ; }
This method formats a SQL string by specifying format arguments
based on restrictions.
This method formats a SQL string by specifying format arguments based on restrictions .
sql
string
restrictions
object[]
defaultRestrictions
object[]