c# - SQL VS EF VS LDAP Connection string TYPE testing -


i have 3 types of connection strings in webconfig, use them various parts of application such ldap login, db status of related non integrated db, , ef db first connection strings (edmx)

i looking parse connection string data in economical way system wise.

<add name="adconnectionstring" connectionstring="ldap://something.somewhere.something:389" /> <add name="dev" connectionstring="data source=source;initial catalog=test;integrated security=false;multipleactiveresultsets=true;app=entityframework;user id=tech;password=*********;" providername="system.data.sqlclient" /> <add name="configentities" connectionstring="metadata=res://*/data.config.csdl|res://*/data.config.ssdl|res://*/data.config.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=source;initial catalog=catalog;persist security info=true;user id=user;password=*********;multipleactiveresultsets=true;application name=entityframework&quot;" providername="system.data.entityclient" /> 

in order process connection strings find need try catch 2 sections in order complete process

first try catch allows skip ldap connection string safely (which should skipped without try catch

second seems need cast strings retrieve data them...

try {     var ssb = new sqlconnectionstringbuilder((((connectionstringsettings)c).connectionstring)); } 

vs

try{         var ssb = new sqlconnectionstringbuilder((new entityconnectionstringbuilder(((connectionstringsettings)c).connectionstring).providerconnectionstring)); } 

from there code identical

does have thoughts on best way determin type of connection string prior running code prevent need rely on try catches.

you can name property of connection string connectionstringsettings. use name property identify type of connection string.

you have connectionstringsettings object, c (based on code snippets).

check name property shown below avoid try statement.

if(c.name.equals("adconnectionstring")) //adconnectionstring {  } else if(c.name.equals("dev")) //dev {      } else //configentities {  } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -