This is a migrated thread and some comments may be shown as answers.
Specifying connection string at run-time
1 Answer 58 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dan
Top achievements
Rank 1
Dan asked on 06 Nov 2009, 02:01 PM

I am trying to determine the best way to specify what OpenAccess connection to use at runtime.  I found 2 different articles Todd Anglin regarding this.

1) http://blogs.telerik.com/blogs/posts/09-01-06/Understanding_Where_to_Set_Connection_Strings_in_OpenAccess.aspx
2) http://blogs.telerik.com/toddanglin/posts/09-01-09/improving_openaccess_objectscopeprovider_for_runtime_connection_config.aspx

In the first article, Todd specifies to use the Telerik.OpenAccess.Database.Get() method to specify a string for the connection name.  I assume after that, you call GetObjectScope on the resulting Database object to get the IObjectScope for execution.  This seems to work for me, but it makes me wonder why article 2 exists and what the generated ObjectScopeProvider1.cs file is really for.  The AdjustForDynamicLoad() method seems to be the only useful method in the generated ObjectScopeProvider1 class and I'm not completely sure what that does, but Todd doesn't modify that in the second article.  Under what circumstances is it necessary to use something other than Database.Get(...).GetObjectScope()?

Thanks in advance,

Lars Solberg

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 06 Nov 2009, 03:41 PM
Hello Lars Solberg,

the ObjectScopeProvider classes are generated by enable project wizard so that our databinding implementations can obtain a Database or ObjectScope. It is perfectly possible to life without an
ObjectScopeProvider! I do that all the time .... :-)
Also, this helper class allows us to obtain the assembly that is trying to open the Database. And in cases, where an entry assembly is not available, the AdjustForDynamicLoad method is needed in order to find the right entries into the configuration.
You can have more than one ObjectScopeProvider too...

Regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Dan
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or