Generated code - CommonDaoBase functionality

Every SelfServicing generated set classes has one class which controls a couple of global settings for the application: CommonDaoBase.cs/vb, located in the DaoClasses namespace. Below are the options it offers as static (shared) options.

Connection strings

The CommonDaoBase class lets you set the global connection string to use for every connection to the database. This setting overrides the connection string read from the appSettings section in the .config file. Once the setting is set, every connection to the database uses the set connection string. You set the connection string to use at runtime using the following code:

CommonDaoBase.ActualConnectionString = "Datasource=myserver;....";

If you want to make the application use the connection string defined in the config file again, simply set the ActualConnectionString property to string.Empty.

Command timeouts

If you want to set the ADO.NET command timeout to a value other than the default of 30 seconds, use the CommonDaoBase.CommandTimeOut property to set it to a different value. This will change the timeout immediately for all calls to the database.

Info

Firebird and SQL Server CE don't support command timeouts.

ArithAbort flag (SQL Server only)

If an entity is saved into a table which is part of an indexed view, SqlServer requires that SET ARITHABORT ON is specified prior to the actual save action. You can tell LLBLGen Pro to set that option, by calling the global method CommonDaoBase.SetArithAbortFlag(bool) method. After each SQL statement a SET ARITHABORT OFF statement will be executed if the ArithAbort flag is set to true. Setting this flag affects all INSERT statements following the call to SetArithAbortFlag(), until you call that method again.

DQE Compatibility mode (SQL Server only)

To set the compatibility mode of the SqlServer DQE in code, you can use the CommonDaoBase method SetSqlServerCompatibilityLevel (SQL Server) or SetFirebirdCompatibilityMode, as shown in the following example which sets the compatibility mode to SqlServer 2012:

CommonDaoBase.SetSqlServerCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012);

The default is SqlServer2005. See for more details about the compatibility parameter and its effect the section: Database specific features and Application configuration through .config files

DQE compatibility mode (Oracle only)

To set the compatibility level for Oracle at runtime, you can use the CommonDaoBase static method SetOracleCompatibilityLevel as shown in the following example, which sets the compatibility level to Oracle 12c:

CommonDaoBase.SetOracleCompatibilityLevel(OracleCompatibilityLevel.Oracle12c);

The default is Oracle9i10g11g. See for more details about the compatibility parameter and its effect the section: Database specific features and Application configuration through .config files