Exemplo n.º 1
0
        public virtual string GetNameOrConnectionString(ConnectionStringResolveArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            var defaultConnectionString = _configuration.DefaultNameOrConnectionString;

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

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

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

            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.");
        }
 protected virtual string ResolveConnectionString(ConnectionStringResolveArgs args)
 {
     return(ConnectionStringResolver.GetNameOrConnectionString(args));
 }