Create Dynamic MongoDB Connection string in AppConfig.xml C#

Viewed 16

Could anyone suggest me how to create and add dynamic connection string in config.xml file in c#? What I want to achieve is I want to pass below connection string in config.xml, and then use and replace the "user" and "Password" as per the parameter passed in the method

"mongodb://" + user + ":" + pass + "@localhost:27017/" + dbname

Here user, pass and dbname will be replaced with the parameter that I'll pass in below method

ConnectToDatabase(string dbname, string user, string pass)
0 Answers
Related