10

I almost ran a query i did not want to against a production db today.

As such i would like to check before all my queries that this.Connection.DataSource is not my production database... and if it is then show a messagebox warning me.

Is this possible?

4imble
  • 13,979
  • 15
  • 70
  • 125
  • I don't think LINQPad has this ability built in. Did you already have a look at creating your own Data Context Driver? http://www.linqpad.net/extensibility.aspx – Frank van Puffelen Feb 25 '14 at 16:43
  • It could work, but I'd want a warning for all queries, just in case it is a costly read or something, not necessarily a write. My current work around against accidental writes is to use an extension method on the data context called ConfirmSubmitChanges this will ask me to confirm that i want to save. This sort of works (providing i always use the extension method) but is still 'flying a little too close to the sun' for my liking. I also added a suggestion i think could work to the uservoice. https://linqpad.uservoice.com/forums/18302-linqpad-feature-suggestions/suggestions/5566477 – 4imble Feb 25 '14 at 16:51
  • It's a similar request to https://linqpad.uservoice.com/forums/18302-linqpad-feature-suggestions/suggestions/4421685-add-server-environment-coloring-in-query-designer and something is currently in the pipeline. Expect a beta build in a day or two! – Joe Albahari Feb 26 '14 at 06:55
  • Excellent, love it :) – 4imble Feb 26 '14 at 09:27

1 Answers1

12

Check out the latest beta. You can now flag connections as 'Production' and you'll see an orange warning banner in the editor margin whenever you use that connection:

Production Connection

Joe Albahari
  • 30,118
  • 7
  • 80
  • 91
  • Very nice, this will no doubt lower my blood pressure significantly :) – 4imble Feb 26 '14 at 10:35
  • 4
    Neat! I'd like to be able to customize the color per-connection so that I could put green for development, yellow for staging, and red for production, but this addition works in a pinch! Thanks. – nemec Apr 30 '14 at 19:51
  • 1
    But is it possible in the code to query this production flag. Something like, if productionConnection then request confirmation. I ask this because I mix config file and there is nothing to load differents config file based on this. – Bastien Vandamme May 15 '17 at 09:40