zoukankan      html  css  js  c++  java
  • 改善应用程序的性能

     1foreach(EventLog log in logList)
     2{
     3CreateEventLog(log);
     4}

     5
     6 CreateEventLog(EventLog eventLog)
     7  {
     8            SqlConnection conn = new SqlConnection(ConnectionString);
     9            SqlHelper.MakeOutParam(cmd, "@ID", SqlDbType.Int, 4);
    10            ……
    11}

    12                                            |
    13                                            |    
    14                                            |
    15
    16CreateEventLogList(List<EventLog> eventLogList)
    17{
    18            SqlConnection conn = new SqlConnection(ConnectionString);
    19            SqlCommand cmd = SqlHelper.PrepareCommand("usp_EventLog_Create", conn, CommandType.StoredProcedure);
    20               ……
    21                conn.Open();
    22                    foreach (EventLog log in eventLogList)
    23                    {
    24                   cmd.Parameters.Clear();
    25                 SqlHelper.MakeInParam(cmd, "@Category", SqlDbType.NVarChar, 20, log.Category);
    26                    ……
    27                     }

    28}
            
    29                                            |
    30                                            |    
    31                                            |
    32
    33CreateEventLogList(List<EventLog> eventLogList)
    34{
    35            SqlConnection conn = new SqlConnection(ConnectionString);
    36            SqlCommand cmd = SqlHelper.PrepareCommand("usp_EventLog_Create", conn, CommandType.StoredProcedure);
    37            SqlHelper.MakeInParam(cmd, "@Category", SqlDbType.NVarChar, 20, DBNull.Value);
    38            ……
    39             conn.Open();
    40                    foreach (EventLog eventLog in eventLogList)
    41                    {
    42                        cmd.Parameters["@Category"].Value = eventLog.Category;
    43                    ……
    44                     }

    45}
            
    46                                       
    47
  • 相关阅读:
    设计模式之迭代器与组合模式(三)
    设计模式之迭代器与组合模式(二)
    设计模式之迭代器与组合模式(一)
    设计模式之模板方法模式(一)
    设计模式之模板方法模式(三)
    设计模式之模板方法模式(二)
    Spring Cloud微服务初探
    设计模式之适配器模式与外观模式(二)
    设计模式之适配器模式与外观模式(一)
    设计模式之命令模式(三)
  • 原文地址:https://www.cnblogs.com/xiaowy/p/476766.html
Copyright © 2011-2022 走看看