當前位置: 首頁>>代碼示例>>C#>>正文


C# NpgsqlConnector.Query方法代碼示例

本文整理匯總了C#中Npgsql.NpgsqlConnector.Query方法的典型用法代碼示例。如果您正苦於以下問題:C# NpgsqlConnector.Query方法的具體用法?C# NpgsqlConnector.Query怎麽用?C# NpgsqlConnector.Query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Npgsql.NpgsqlConnector的用法示例。


在下文中一共展示了NpgsqlConnector.Query方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExecuteBlindSuppressTimeout

        internal static void ExecuteBlindSuppressTimeout(NpgsqlConnector connector, NpgsqlQuery query)
        {
            // Block the notification thread before writing anything to the wire.
            using (var blocker = connector.BlockNotificationThread())
            {
                // Write the Query message to the wire.
                connector.Query(query);

                // Flush, and wait for and discard all responses.
                connector.ProcessAndDiscardBackendResponses();
            }
        }
開發者ID:baondp,項目名稱:Npgsql,代碼行數:12,代碼來源:NpgsqlCommand.PrepareExecute.cs

示例2: ExecuteBlind

        private static void ExecuteBlind(NpgsqlConnector connector, NpgsqlQuery query, int timeout)
        {
            // Block the notification thread before writing anything to the wire.
            using (var blocker = connector.BlockNotificationThread())
            {
                // Set statement timeout as needed.
                connector.SetBackendCommandTimeout(timeout);

                // Write the Query message to the wire.
                connector.Query(query);

                // Flush, and wait for and discard all responses.
                connector.ProcessAndDiscardBackendResponses();
            }
        }
開發者ID:undeadlabs,項目名稱:Npgsql,代碼行數:15,代碼來源:NpgsqlCommand.PrepareExecute.cs

示例3: TestNotify

 public void TestNotify(NpgsqlConnector context)
 {
     //ZA  Hnotifytest CNOTIFY Z
     //Qlisten notifytest;notify notifytest;
     Stream stm = context.Stream;
     string uuidString = "uuid" + Guid.NewGuid().ToString("N");
     PGUtil.WriteString("Qlisten " + uuidString + ";notify " + uuidString + ";", stm);
     Queue<byte> buffer = new Queue<byte>();
     byte[] convertBuffer = new byte[36];
     for (;;)
     {
         int newByte = stm.ReadByte();
         if (newByte == -1)
         {
             throw new EndOfStreamException();
         }
         buffer.Enqueue((byte) newByte);
         if (buffer.Count > 35)
         {
             buffer.CopyTo(convertBuffer, 0);
             if (ENCODING_UTF8.GetString(convertBuffer) == uuidString)
             {
                 for (;;)
                 {
                     switch (stm.ReadByte())
                     {
                         case -1:
                             throw new EndOfStreamException();
                         case 'Z':
                             //context.Query(new NpgsqlCommand("UNLISTEN *", context));
                             using(NpgsqlCommand cmd = new NpgsqlCommand("UNLISTEN *", context))
                             {
                                 context.Query(cmd);
                             }
                             return;
                     }
                 }
             }
             else
             {
                 buffer.Dequeue();
             }
         }
     }
 }
開發者ID:Qorpent,項目名稱:Npgsql2,代碼行數:45,代碼來源:NpgsqlState.cs

示例4: ExecuteSetStatementTimeoutBlind

        /// <summary>
        /// Special adaptation of ExecuteBlind() that sets statement_timeout.
        /// This exists to prevent Connector.SetBackendCommandTimeout() from calling Command.ExecuteBlind(),
        /// which will cause an endless recursive loop.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="timeout">Timeout in seconds.</param>
        internal static void ExecuteSetStatementTimeoutBlind(NpgsqlConnector connector, int timeout)
        {
            NpgsqlQuery query;

            // Optimize for a few common timeout values.
            switch (timeout)
            {
                case 10 :
                    query = NpgsqlQuery.SetStmtTimeout10Sec;
                    break;

                case 20 :
                    query = NpgsqlQuery.SetStmtTimeout20Sec;
                    break;

                case 30 :
                    query = NpgsqlQuery.SetStmtTimeout30Sec;
                    break;

                case 60 :
                    query = NpgsqlQuery.SetStmtTimeout60Sec;
                    break;

                case 90 :
                    query = NpgsqlQuery.SetStmtTimeout90Sec;
                    break;

                case 120 :
                    query = NpgsqlQuery.SetStmtTimeout120Sec;
                    break;

                default :
                    query = new NpgsqlQuery(string.Format("SET statement_timeout = {0}", timeout * 1000));
                    break;

            }

            // Write the Query message to the wire.
            connector.Query(query);

            // Flush, and wait for and discard all responses.
            connector.ProcessAndDiscardBackendResponses();
        }
開發者ID:baondp,項目名稱:Npgsql,代碼行數:50,代碼來源:NpgsqlCommand.PrepareExecute.cs

示例5: ExecuteSetStatementTimeoutBlind

        /// <summary>
        /// Special adaptation of ExecuteBlind() that sets statement_timeout.
        /// This exists to prevent Connector.SetBackendCommandTimeout() from calling Command.ExecuteBlind(),
        /// which will cause an endless recursive loop.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="timeout">Timeout in seconds.</param>
        internal static void ExecuteSetStatementTimeoutBlind(NpgsqlConnector connector, int timeout)
        {
            NpgsqlQuery query;

            // Bypass cpmmand parsing overhead and send command verbatim.
            query = NpgsqlQuery.Create(connector.BackendProtocolVersion, string.Format("SET statement_timeout = {0}", timeout * 1000));

            // Write the Query message to the wire.
            connector.Query(query);

            // Flush, and wait for and discard all responses.
            connector.ProcessAndDiscardBackendResponses();
        }
開發者ID:undeadlabs,項目名稱:Npgsql,代碼行數:20,代碼來源:NpgsqlCommand.PrepareExecute.cs


注:本文中的Npgsql.NpgsqlConnector.Query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。