2009-06-30 85 views
0

我目前面临着亚音速配置的问题。亚音速在视觉工作室设计主机

我想实现的是在System.Web.UI.Design.ControlDesigner类中使用亚音速数据访问。

该类托管在Visual Studio环境中,并对附加的System.Web.UI.WebControls.Control启用设计时操作。

唯一的问题是SubSonic似乎总是在应用程序配置中寻找SubSonicSection,无论将连接字符串传递给它。

相关的代码片断:

using (SharedDbConnectionScope dbScope = new SharedDbConnectionScope(new SqlDataProvider(), ConnectionString)) 
{ 
Table1 _table1 = new Select().From<..().Where(...).IsEqualTo(...).ExecuteSingle<...>(); 

抛出上ExecuteSingle))的异常(方法(未找到配置部分)

using (SharedDbConnectionScope dbScope = new SharedDbConnectionScope(ConnectionString)) 
{ 

抛出新SharedDbConnectionScope异常((配置部分未找到)

S Ø问题是:
有没有办法通过设置运行时绕过配置部分查找,因为我不希望添加任何亚音速具体的配置devenv.configuration

感谢

回答

0

我不t认为你可以在2.x中做到这一点,而无需自定义模板(当SubSonic的新版本发布时,这显然会给支持问题)。

对不起,不知道3.0

0

使用亚音速运行时提供配置的方法:

(示例):

private void SetSubsonicProviderManually(string ConnectionString) 
{ 
//clear the providers and reset 
DataService.Provider = new SqlDataProvider(); 
DataService.Providers = new DataProviderCollection(); 

//instance a section - we'll set this manually for the DataService 
SubSonicSection section = new SubSonicSection(); 
section.DefaultProvider = __SubsonicProviderName__; 

//set the properties 
DataProvider provider = DataService.Provider; 
NameValueCollection config = new NameValueCollection(); 

//need to add this for now 
config.Add("connectionStringName", __ConnectionString__); 

//initialize the provider 
provider.Initialize(__SubsonicProviderName__, config); 

provider.DefaultConnectionString = ConnectionString; 

DataService.Providers.Add(provider); 

}