Ejemplo n.º 1
0
        public DapperClient GetClient(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var          clients = _optionsMonitorClient.Get("DbConnedtions").DapperDictionary;
            DapperClient client  = null;

            foreach (var(key, value) in clients)
            {
                if (key == name)
                {
                    client = value;
                    break;
                }
            }
            return(client);
        }
        public DapperClient CreateClient(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var client = new DapperClient(new ConnectionConfig {
            });

            var option = _optionsMonitor.Get(name).DapperActions.FirstOrDefault();

            if (option != null)
            {
                option(client.CurrentConnectionConfig);
            }
            else
            {
                throw new ArgumentNullException(nameof(option));
            }

            return(client);
        }