1 Using SQL Escape Sequences in .NET Applications : SQL Extension Escape

SQL Extension Escape
The RowSetSize property of the ProviderCommand object allows applications to limit the size of the result set returned (refer to the DataDirect Connect for ADO.NET User’s Guide and the data provider’s online help for information about the .NET objects supported).
NOTE: The Entity Framework data providers use the ADO.NET Entity Framework programming contexts instead of using the RowSetSize property.
Developers must set the property explicitly, for example:
OracleCommand.RowSetSize = 10;
PropertyInfo info = DbCommand cmd = conn.createCommand();
Although using the provider-specific RowSetSize property is convenient, it means that the programmer cannot code to generic ADO.NET interfaces such as IDbCommand.
To increase the interoperability of the code, developers can use the SQL extension escape for the RowSetSize property instead. For example:
my_SQL_statement {ext RowSetSize x}
where my_SQL_statement is a SQL statement, and x is the number of rows to which the application wants the result set limited.
This extension can be used with any SQL statement. However, if the statement generates no results, for example, a DELETE statement, then the extension has no effect.
NOTE: The SQL extension escape must be placed at the end of the SQL statement. Otherwise, the database server may return a syntax error when the statement is executed.
Using the RowSetSize SQL escape extension has the same affect as setting the ProviderCommand.RowSetSize property. However, the effect is limited to the result set created by the SQL statement. The RowSetSize SQL escape extension does not set the RowSetSize property on the Command object.
Example
SELECT * FROM mytable WHERE mycolumn2 >100 {ext RowSetSize 100}
A maximum of 100 rows are returned from the result set. If the result set contains less than 100 rows, then the SQL extension escape has no affect. The size of the result sets that are created by subsequent SQL statements is not limited.
If the application contains both the RowSetSize SQL extension escape and the RowSetSize property for a command, the escape takes precedence.