Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Specifying configuration information using XMLElement
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Configuration File > Specifying configuration information using XMLElement

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

To specify configuration information programmatically, instead of putting the information into the App.config file, an instance of XMLElement can be specified for Database.Get(). This information overrides the information, if the same is present in the App.config file.

It is not supported to specify different configuration information for the same connectionId in subsequent calls, also it is not supported, to use Database.Get() one time with and one time without an XMLElement for the same connectionId. The behavior is not specified for this case.

None of the OpenAccess ORM tools can read the passed config override, so use with care!

An example using the XMLElement is given below:

C# Copy Code
const string myconfig=
"<reference assemblyname='ClassLibrary1'/>"+
"<connection id='DatabaseConnection1'>"+
"<backendconfiguration id='mssqlConfiguration' backend='mssql'>"+
"<mappings current='mssqlMapping'>"+
"<mapping id='mssqlMapping'/>"+
XmlDocument xmlDoc =
new XmlDocument();
Database db = Database.Get(
"DatabaseConnection1", xmlDoc.DocumentElement);

The XMLElement represents the OpenAccess ORM-node and all subnodes, of the configuration. This is used instead of the OpenAccess ORM node in the application configuration file. However this does not necessarily replace the mapping nodes of other referenced assemblies: The mapping configuration of those is still used when referenced (via the reference subelement) from the passed configOverride node.

The following returns the database instance:

C# Copy Code
public static Database Get(string connectionId, XmlElement configOverride)
return reg.GetDatabase(connectionId, configOverride);


VB .NET Copy Code
Public Shared Function [Get](ByVal connectionId As String, ByVal configOverride As XmlElement) As Database
 Return reg.GetDatabase(connectionId, configOverride)
End Function