Skip to content
Ophir Oren edited this page Feb 17, 2015 · 4 revisions

Poco.Sql allows you to configure it's behavior, which affects the way it creates queries, handle caching and map objects.

To configure Poco.Sql you use the static Initialize method inside the Configuration class of Poco.Sql library.

Configuration.Initialize(config =>
{
    // configuration
}

The configuration object supports the following configuration options:

Name Method Description
AddMap AddMap(PocoSqlMapping mapping) Adds class mapping definition class. Read more about Mapping
DisableCache DisableCache() Query caching is enabled by default to cache generated queries of objects to make query generation faster. This method disables the use of cahching queries.
InjectValuesInQueies InjectValuesInQueies() By default, generated queries are parameterized. Enabling this option will inject the values from the POCO object directly to the query.
PluralizeTableNames PluralizeTableNames() This option will pluralize table names in the query. Example user will become users.
SelectFullGraph SelectFullGraph() This will direct the query builder to analyze the properties of the object and create additional queries to select sub-objects from the object hierarchy.
SetStoreProcedurePrefix SetStoreProcedurePrefix(string prefix) This will add the prefix to every mapped stored procedure.
ShowComments ShowComments() This is used for debugging, And adds SQL comments to every generated query.

Example:

Configuration.Initialize(config =>
{
    config.PluralizeTableNames();
    config.SetStoreProcedurePrefix("stp_");
    config.ShowComments();
    config.InjectValuesInQueies();
    config.SelectFullGraph();

    config.AddMap(new UserMap());
    config.AddMap(new OrderMap());
    config.AddMap(new VUserMap());
});
Clone this wiki locally