当前位置: 首页>>代码示例>>C#>>正文


C# IDbConnection.EnsureOpen方法代码示例

本文整理汇总了C#中IDbConnection.EnsureOpen方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.EnsureOpen方法的具体用法?C# IDbConnection.EnsureOpen怎么用?C# IDbConnection.EnsureOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbConnection的用法示例。


在下文中一共展示了IDbConnection.EnsureOpen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildSchema

        public void BuildSchema(IDbConnection conn)
        {
            conn.EnsureOpen();

            foreach (string statement in createSql)
                conn.Execute(statement);
        }
开发者ID:civicsource,项目名称:data,代码行数:7,代码来源:Database.cs

示例2: UnitOfWork

        public UnitOfWork(IDbConnection connection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");

            _connection = connection;
            connection.EnsureOpen();
            _transaction = connection.BeginTransaction();
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:9,代码来源:UnitOfWork.cs

示例3: ExecuteReader

        /// <summary>
        ///   Sorguyu belirtilen bağlantı üzerinde çalıştırır ve bir IDataReader nesnesi döndürür.</summary>
        /// <param name="connection">
        ///   Sorgunun çalıştırılacağı bağlantı. Açık değilse otomatik olarak açılır.</param>
        /// <param name="commandText">
        ///   Çalıştırılacak SQL sorgusu.</param>
        /// <param name="param">
        ///   Parameters (optional).</param>
        /// <returns>
        ///   Sorgunun çalıştırılması sonucu elde edilen IDataReader nesnesi.</returns>
        public static IDataReader ExecuteReader(IDbConnection connection, string commandText,
            IDictionary<string, object> param)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");

            connection.EnsureOpen();

            try
            {
                //using (new Tracer(commandText))
                {
                    IDbCommand command = NewCommand(connection, commandText, param);
                    try
                    {
                        if (Log.IsDebugEnabled)
                            LogCommand("ExecuteReader", command);

                        var result = command.ExecuteReader();

                        if (Log.IsDebugEnabled)
                            Log.Debug("END - ExecuteReader");

                        return result;
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        if (CheckConnectionPoolException(connection, ex))
                            return command.ExecuteReader();
                        else
                            throw;
                    }
                }
            }
            catch (Exception ex)
            {
                ex.SetData("sql_command_text", commandText);
                throw;
            }
        }
开发者ID:fzhenmei,项目名称:Serenity,代码行数:50,代码来源:SqlHelper.cs

示例4: Clear

        public void Clear(IDbConnection conn)
        {
            conn.EnsureOpen();

            using (var tx = conn.BeginTransaction())
            {
                foreach (string statement in clearSql)
                    conn.Execute(statement, transaction: tx);

                tx.Commit();
            }
        }
开发者ID:civicsource,项目名称:data,代码行数:12,代码来源:Database.cs


注:本文中的IDbConnection.EnsureOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。