Example #1
0
        public virtual string GetNameOrConnectionString(ConnectionStringResolveArgs args)
        {
            Check.NotNull(args, nameof(args));

            var defaultConnectionString = _configuration.DefaultNameOrConnectionString;

            if (!string.IsNullOrWhiteSpace(defaultConnectionString))
            {
                return(defaultConnectionString);
            }

#if NET46
            if (ConfigurationManager.ConnectionStrings["Default"] != null)
            {
                return("Default");
            }

            if (ConfigurationManager.ConnectionStrings.Count == 1)
            {
                return(ConfigurationManager.ConnectionStrings[0].ConnectionString);
            }
#endif

            throw new AbpException("Could not find a connection string definition for the application. Set IAbpStartupConfiguration.DefaultNameOrConnectionString or add a 'Default' connection string to application .config file.");
        }
Example #2
0
 protected virtual string ResolveConnectionString(ConnectionStringResolveArgs args)
 {
     return(ConnectionStringResolver.GetNameOrConnectionString(args));
 }
 public virtual Task <string> GetNameOrConnectionStringAsync(ConnectionStringResolveArgs args)
 {
     return(Task.FromResult(GetNameOrConnectionString(args)));
 }
 protected virtual async Task <string> ResolveConnectionStringAsync(ConnectionStringResolveArgs args)
 {
     return(await ConnectionStringResolver.GetNameOrConnectionStringAsync(args));
 }