Executing Custom Queries
As powerful as this library is, there are sometimes situations where you need to execute a specialized SQL statement. You can use this technique for selecting, inserting, updating and deleting rows. In this example, we are showing how to SELECT from a database:
public static IEnumerable<TableClassName > GetAll(string aQuery)
foreach( TableClassName ROW in Repository.GetTemporaryDatabaseConnection()
.Query<TableClassName>( "select * from TableClassName where Field like ?", new object[] { aQuery } ) ) {
yield return ROW;
}
When executing INSERT statements, expect one integer return of the OID. For update statements, you will need a separate value for each "?" in your SQL statement.
public static IEnumerable<TableClassName > GetAll(string aQuery)
foreach( TableClassName ROW in Repository.GetTemporaryDatabaseConnection()
.Query<TableClassName>( "select * from TableClassName where Field like ?", new object[] { aQuery } ) ) {
yield return ROW;
}
When executing INSERT statements, expect one integer return of the OID. For update statements, you will need a separate value for each "?" in your SQL statement.