vb.net - Assigning DataContext to a public variable -


i'm messing linq, , i'm trying save lines of code. created variable in settings indicate if i'm in stage or production, , need able switch between 2 versions of database testing purposes. like create function handle datacontext me can call when want create queries. here's i'm working far:

public class dataclass public env string = my.settings.environ public proddatastring string = my.settings.prodconnectionstring public stagedatastring string = my.settings.stageconnectionstring public pconn productiondatacontext public sconn stagedatacontext  'to return datacontext public function coninit() datacontext         if env = "production"             return pconn         else             return sconn         end if end function  'to return connection string public function strinit() string         if env = "production"             return proddatastring         else             return stagedatastring         end if end function  end class 

now, in function, tried set datacontext variable so: dim dconn new datacontext(strinit()) tried using this: dconn = coninit()

but doesn't seem take. suggestions? i'm going wrong way, if that's case, tips? know can put in every function

if env = "production"    dim query = r in pconn.table... 

but i'd prefer not to. thanks!


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -