Example #1
0
        public static void BulkInsert <T>(this TdsConnectionPool tdsConnectionPool, IEnumerable <T> objects, string tableName, Dictionary <string, PropertyInfo> columnMapping)
        {
            var cnn = tdsConnectionPool.GetConnection();

            cnn.BulkInsert(objects, tableName, columnMapping);
            tdsConnectionPool.Return(cnn);
        }
Example #2
0
        public static void ExecuteNonQuery(this TdsConnectionPool tdsConnectionPool, string text)
        {
            var cnn = tdsConnectionPool.GetConnection();

            cnn.ExecuteNonQuery(text);
            tdsConnectionPool.Return(cnn);
        }
Example #3
0
        public static void BulkInsert <T>(this TdsConnectionPool tdsConnectionPool, IEnumerable <T> objects, string tableName)
        {
            var cnn = tdsConnectionPool.GetConnection();

            cnn.BulkInsert(objects, tableName);
            tdsConnectionPool.Return(cnn);
        }
Example #4
0
        public void LifeTimeIsTakenInAccount()
        {
            var SMALLEST_LIFETIME_TO_TEST    = 1;
            var WAIT_TO_MAKE_LIFETIME_PASSED = 2;

            TdsConnectionPoolManager sqlConnectionPools = new FakeConnectionPoolManager();
            TdsConnectionInfo        info = new TdsConnectionInfo("dummy", 0, 0, 0,
                                                                  1 /*minpoolsize*/,
                                                                  1 /*maxpoolsize*/,
                                                                  SMALLEST_LIFETIME_TO_TEST /*lifetime*/);

            TdsConnectionPool pool = sqlConnectionPools.GetConnectionPool("test", info);

            Mono.Data.Tds.Protocol.Tds tds, tds2 = null;

            tds = pool.GetConnection();

            System.Threading.Thread.Sleep(TimeSpan.FromSeconds(WAIT_TO_MAKE_LIFETIME_PASSED));
            pool.ReleaseConnection(tds);

            tds2 = pool.GetConnection();


            Assert.IsFalse(object.ReferenceEquals(tds, tds2));
            pool.ReleaseConnection(tds2);
        }
Example #5
0
        public static List <T> ExecuteParameterQuery <T>(this TdsConnectionPool tdsConnectionPool, FormattableString text) where T : class, new()
        {
            var cnn    = tdsConnectionPool.GetConnection();
            var result = cnn.ExecuteParameterQuery <T>(text);

            tdsConnectionPool.Return(cnn);
            return(result);
        }
Example #6
0
 public void TearDown()
 {
     Console.WriteLine("Tear down start!");
     TdsConnectionPool.Clear();
     server.Stop();
     stopped.Release();
     Console.WriteLine("Tear down end!");
 }
Example #7
0
        public MedellaOrm()
        {
            var connections = new TdsConnection[conc];

            _tds = TdsConnectionPools.GetConnectionPool(_connectionString);
            var task = Parallel.For(0, conc, (x) => connections[x] = _tds.GetConnection());

            //OrmTester.EnsureDbSetup(_connectionString);
            task = Parallel.For(0, conc, (x) => _tds.Return(connections[x]));
        }
Example #8
0
        void Open()
        {
            string serverName = "";

            if (connectionString == null || connectionString.Equals(""))
            {
                throw new InvalidOperationException("Connection string has not been initialized.");
            }

            try {
                if (!pooling)
                {
                    ParseDataSource(dataSource, out port, out serverName);
                    tds = new Tds50(serverName, port, PacketSize, ConnectionTimeout);
                }
                else
                {
                    ParseDataSource(dataSource, out port, out serverName);
                    TdsConnectionInfo info = new TdsConnectionInfo(serverName, port, packetSize, ConnectionTimeout, minPoolSize, maxPoolSize);
                    pool = sybaseConnectionPools.GetConnectionPool(connectionString, info);
                    tds  = pool.GetConnection();
                }
            }
            catch (TdsTimeoutException e) {
                throw SybaseException.FromTdsInternalException((TdsInternalException)e);
            }

            tds.TdsErrorMessage += new TdsInternalErrorMessageEventHandler(ErrorHandler);
            tds.TdsInfoMessage  += new TdsInternalInfoMessageEventHandler(MessageHandler);

            if (!tds.IsConnected)
            {
                try {
                    tds.Connect(parms);
                    ChangeState(ConnectionState.Open);
                    ChangeDatabase(parms.Database);
                }
                catch {
                    if (pooling)
                    {
                        pool.ReleaseConnection(tds);
                    }
                    throw;
                }
            }
            else if (connectionReset)
            {
                // tds.ExecuteNonQuery ("EXEC sp_reset_connection"); FIXME
                ChangeState(ConnectionState.Open);
            }
        }
Example #9
0
 public static async Task ExecuteNonQueryAsync(this TdsConnectionPool tdsConnectionPool, string text) => await Task.Run(() => ExecuteNonQuery(tdsConnectionPool, text));
Example #10
0
 public static async Task BulkInsertAsync <T>(this TdsConnectionPool tdsConnectionPool, IEnumerable <T> objects, string tableName)
 {
     await Task.Run(() => BulkInsert(tdsConnectionPool, objects, tableName));
 }
Example #11
0
 public static async Task BulkInsertAsync <T>(this TdsConnectionPool tdsConnectionPool, IEnumerable <T> objects, string tableName, Dictionary <string, PropertyInfo> columnMapping)
 {
     await Task.Run(() => BulkInsert(tdsConnectionPool, objects, tableName, columnMapping));
 }
Example #12
0
 public static async Task <List <T> > ExecuteParameterQueryASync <T>(this TdsConnectionPool tdsConnectionPool, FormattableString text) where T : class, new() => await Task.Run(() => ExecuteParameterQuery <T>(tdsConnectionPool, text));
Example #13
0
 public static async Task <List <T> > ExecuteQueryAsync <T>(this TdsConnectionPool tdsConnectionPool, string text) where T : class, new() => await Task.Run(() => ExecuteQuery <T>(tdsConnectionPool, text));