Beyond all the basic filtering available in Fetch methods and collection filtering, SubSonic also provides a way to dynamically build SQL queries. To get started, create a new Query object, using the CreateQuery method.

SubSonic.Query query = Product.CreateQuery();

or pass it the table name

SubSonic.Query query = new SubSonic.Query(product.TableName);

or pass it the table schema

SubSonic.Query query = new SubSonic.Query(Product.GetTableSchema());

The last option will prevent SubSonic from loading the table information from the database, eliminating an extra call.

Note: You can also get the table schema by calling the static method BuildTableSchema or the property Schema.

Running the Query

Executing the query follows the same rules as executing ADO.NET queries. The Execute method runs the query and returns nothing.