﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Dynamic DataSourceKey?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 09 Sep 2026 07:24:49 GMT</lastBuildDate><ttl>20</ttl><item><title>Dynamic DataSourceKey?</title><link>http://forum.strataframe.net/FindPost23527.aspx</link><description>Hi,&lt;br&gt;
I want on fly in my application switch between databases, each of them has own DataSourceKey.&lt;br&gt;
&lt;br&gt;
My problem is - If I not write  the DataSourceKey hardcoded for BO component, I have an error like DataSourceKey is empty...&lt;br&gt;
The question is - how can I make dynamic datasourcekey and also.. question.. can businessobjectmapper as default take my subclass of businesslayer, where I can add additional standard functionality for my projects.&lt;br&gt;
&lt;br&gt;
For this purpose I thought to do&lt;br&gt;
&lt;br&gt;
[code]&lt;br&gt;
Public Class PSOFormStore_PensBO&lt;br&gt;
    Inherits MicroFour.StrataFrame.Business.BusinessLayer&lt;br&gt;
&lt;br&gt;
#Region " Data Retrieval Methods "&lt;br&gt;
&lt;br&gt;
    Overloads ReadOnly Property DataSourceKey() As String&lt;br&gt;
        Get&lt;br&gt;
             Return(DatabaseManager.GetCurrentDataSourceKey())&lt;br&gt;
        End Get&lt;br&gt;
    End Property&lt;br&gt;
#End Region&lt;br&gt;
End Class&lt;br&gt;
&lt;br&gt;
Public Class DatabaseManager&lt;br&gt;
     Public Shared Function GetCurrentDataSourceKey() as String&lt;br&gt;
        Return("TEST")&lt;br&gt;
     End Func&lt;br&gt;
End Class&lt;br&gt;
[/code]</description><pubDate>Wed, 17 Jun 2009 06:55:01 GMT</pubDate><dc:creator>dgsoft</dc:creator></item><item><title>RE: Dynamic DataSourceKey?</title><link>http://forum.strataframe.net/FindPost23529.aspx</link><description>If you change the data source key of a BO instance, you will have call the ReCreateDataLayer method on the BO to have it pull from the new data source key.  That is the ONLY trick. &lt;br&gt;
&lt;br&gt;
[codesnippet]MyBO.DataSourceKey = "NewKey"&lt;br&gt;
MyBO.ReCreateDataLayer()[/codesnippet]&lt;br&gt;
&lt;br&gt;
As for creating a subclassed BO, that is not something you need to do through the BO Mapper.  When you create a new BusinessLayer, just change the inheritance once.  This is done in the main class instead of the Designer file so that the BO Mapper leaves the inheritance alone.  But if you put the inheritance declaration on the partial class (designer file) it will be overwritten every time the partial is rebuilt.  This is why, by default, we put the inheritance in the main file.  That is all that is required.</description><pubDate>Wed, 17 Jun 2009 06:55:01 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>