I have two Repositories IntegrationRepo and OtherEnvironmentRepo. I am trying to initialize the repository at runtime based on a string (domain where I am running), but getting error:
************************************************************
//code snippet sample:
// declare the repo with base class
RepoGenBaseFolder repo;
//initialize the Repo based on the string strDomain
repo = strDomain == "integration.testdomain.com" ? IntegrationRepo.Instance : OtherEnvironmentRepo.Instance;
Type of conditional expression cannot be determined because there is no implicit conversion between 'IntegrationRepo' and 'OtherEnvironmentRepo' (CS0173)
How can I solve this?
initialize the repository at runtime based on a string
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: initialize the repository at runtime based on a string
Hello,
Please try out the following code:
Markus (T)
Please try out the following code:
repo = strDomain == "integration.testdomain.com" ? (RepoGenBaseFolder)IntegrationRepo.Instance : (RepoGenBaseFolder)OtherEnvironmentRepo.Instance;I would use a if-statement as shown below:
if (strDomain == "integration.testdomain.com") repo = IntegrationRepo.Instance; else repo = OtherEnvironmentRepo.Instance;Regards,
Markus (T)