Generated code - CommonDaoBase functionality

Preface

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:

// C#
CommonDaoBase.ActualConnectionString = "Datasource=myserver;....";
' VB.NET
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.

note Note:
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 / Firebird only)

To set the compatibility mode of the SqlServer DQE or Firebird DQE in code, you can use the CommonDaoBase method SetSqlServerCompatibilityLevel, as shown in the following example which sets the compatibility mode to SqlServer 2005:

// C#
CommonDaoBase.SetSqlServerCompatibilityLevel( SqlServerCompatibilityLevel.SqlServer2005 );
' VB.NET
CommonDaoBase.SetSqlServerCompatibilityLevel( SqlServerCompatibilityLevel.SqlServer2005 )

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

LLBLGen Pro Runtime Framework v3.5 documentation. ©2012 Solutions Design bv