コード例 #1
0
ファイル: SqlLogEntity.cs プロジェクト: 9073194/Farseer.Net
 /// <summary> SQL执行记录写入~/App_Data/SqlLog.xml </summary>
 /// <param name="name">表名称</param>
 /// <param name="sql">T-SQL</param>
 /// <param name="param">SQL参数</param>
 /// <param name="elapsedMilliseconds">执行时间(单位:ms)</param>
 public static void Write(string name, string sql, List<DbParameter> param, long elapsedMilliseconds)
 {
     var entity = new SqlLogEntity
     {
         Name = name,
         SqlParamList = new List<SqlParam>(),
         Sql = sql ?? "",
     };
     if (param != null && param.Count > 0) { param.ForEach(o => entity.SqlParamList.Add(new SqlParam { Name = o.ParameterName, Value = (o.Value ?? "null").ToString() })); }
     entity.Write(elapsedMilliseconds);
 }
コード例 #2
0
        /// <summary> SQL执行记录写入~/App_Data/SqlLog.xml </summary>
        /// <param name="name">表名称</param>
        /// <param name="sql">T-SQL</param>
        /// <param name="param">SQL参数</param>
        /// <param name="elapsedMilliseconds">执行时间(单位:ms)</param>
        public static void Write(string name, string sql, List <DbParameter> param, long elapsedMilliseconds)
        {
            var entity = new SqlLogEntity
            {
                Name         = name,
                SqlParamList = new List <SqlParam>(),
                Sql          = sql ?? "",
            };

            if (param != null && param.Count > 0)
            {
                param.ForEach(o => entity.SqlParamList.Add(new SqlParam {
                    Name = o.ParameterName, Value = (o.Value ?? "null").ToString()
                }));
            }
            entity.Write(elapsedMilliseconds);
        }