Is it possible to update linqpad.config settings on the fly?
We are using LinqPad to script against the Umbraco API. On the whole this is working well for us.
The only thing I don't like is that Umbraco requires an "umbracoDbDSN" connection string in the config file. Now, I can put this in linqpad.config and it does work. However, there are two problems:
Firstly, it's a bit misleading. I can select a connection string in LinqPad, but the one it uses is one I can't see when I'm executing my scripts - this is doubly confusing as some of our scripts access the database as well.
Secondly, it's a pain to swap between different Umbraco instances as I need to keep closing and reopening LinqPad.
Which is to say - is there anything I can do to set config settings on the fly? In an ideal world I would do:
ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString = this.Connection.ConnectionString;
But I get an exception because the configuration is readonly. From googling it looks like I need to open the config file, make the change, save it and then refresh the section. But in LinqPad it's not quite normal (as it uses linqpad.config and not linqpad.exe.config (not sure if I would need to open the config as an XDocument and do it that way). But that feels a bit unwieldy.
I'm just wondering if there is any way I could either tell LinqPad to use a different config file for a particular script and load it on the fly, or if I could somehow modify the settings it uses? Or even if I could pass a commandline option to tell it what config to use, that might be better.
Sorry I know this might be a bit of an obscure question to ask, and from a rummage around reflecting the linqpad source it looks like I probably can't, but I thought I would try my luck anyway! (I guess the ideal is to try to persuade Umbraco to make changes so that the API can work without a config file)
Thanks!
The only thing I don't like is that Umbraco requires an "umbracoDbDSN" connection string in the config file. Now, I can put this in linqpad.config and it does work. However, there are two problems:
Firstly, it's a bit misleading. I can select a connection string in LinqPad, but the one it uses is one I can't see when I'm executing my scripts - this is doubly confusing as some of our scripts access the database as well.
Secondly, it's a pain to swap between different Umbraco instances as I need to keep closing and reopening LinqPad.
Which is to say - is there anything I can do to set config settings on the fly? In an ideal world I would do:
ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString = this.Connection.ConnectionString;
But I get an exception because the configuration is readonly. From googling it looks like I need to open the config file, make the change, save it and then refresh the section. But in LinqPad it's not quite normal (as it uses linqpad.config and not linqpad.exe.config (not sure if I would need to open the config as an XDocument and do it that way). But that feels a bit unwieldy.
I'm just wondering if there is any way I could either tell LinqPad to use a different config file for a particular script and load it on the fly, or if I could somehow modify the settings it uses? Or even if I could pass a commandline option to tell it what config to use, that might be better.
Sorry I know this might be a bit of an obscure question to ask, and from a rummage around reflecting the linqpad source it looks like I probably can't, but I thought I would try my luck anyway! (I guess the ideal is to try to persuade Umbraco to make changes so that the API can work without a config file)
Thanks!
Comments