コード例 #1
0
        public Dictionary <string, string> GetTable()
        {
            //for demo purposes, I will create a dictionary here.
            var data = new Dictionary <string, string>();

            data.Add(_tenantIdStrategy.CurrentTenant, _connectionStringProvider.ConnectionString());

            return(data);
        }
コード例 #2
0
        public IDapperSession GetSession(string connectionStringName)
        {
            if (string.IsNullOrWhiteSpace(connectionStringName))
            {
                throw new ArgumentNullException(nameof(connectionStringName));
            }

            var connection = _configuration.Dialect.GetConnection(_connectionStringProvider.ConnectionString(connectionStringName));

            _logger.LogDebug($"get session for {connectionStringName}");

            return(new DapperSession(connection));
        }
コード例 #3
0
        public IDictionary <string, IDapperSession> OpenAndBind()
        {
            IDictionary <string, IDapperSession> result = new Dictionary <string, IDapperSession>();
            var conStrings = GetAllLoadedContexts();

            foreach (var conString in conStrings)
            {
                IConnectionStringProvider provider = GetCsProvider(conString);
                var connection = _configuration.Dialect.GetConnection(provider.ConnectionString(conString));
                connection.Open();

                var session = new DapperSession(connection);
                result.Add(conString, session);
            }

            return(result);
        }
コード例 #4
0
 public IScheduleContext BuildContext()
 {
     return(new ScheduleContext(_connectionStringProvider.ConnectionString(_scheduleConnectionKey)));
 }