Programmatically determine if linqpad script running against production connection string

Viewed 107

When I'm running queries in Linqpad I'd like to do some extra checking when the query is being run against a production database, is there a way of detecting programmatically if the connection string that's active for the current linqpad script is marked as production?

1 Answers

Yes, you can get the current connection information using:

 Util.CurrentQuery.GetConnectionInfo()

Which returns an object that contains a IsProduction boolean property, which is True if the connection is marked as such in the connection properties.

Related