コード例 #1
0
ファイル: DbProfiling.cs プロジェクト: christianz/Monocle
        public static void AddResult(DbProfilingResults result)
        {
            Results.Add(result);

            var query = result.Query;

            if (!QueryTimings.ContainsKey(query))
                QueryTimings[query] = new QueryRunResult();

            QueryTimings[query].AddElapsed(result.ElapsedMilliseconds);
        }
コード例 #2
0
ファイル: MsSqlProfiler.cs プロジェクト: christianz/Monocle
        public void StartProfiling(SqlCommand command)
        {
            var query = command.CommandText;

            foreach (SqlParameter param in command.Parameters)
            {
                var val = param.Value.ToString();

                if (param.SqlDbType == SqlDbType.UniqueIdentifier || param.SqlDbType == SqlDbType.Text || param.SqlDbType == SqlDbType.DateTime)
                {
                    val = "'" + val + "'";
                }

                query = query.Replace("@" + param.ParameterName, val);
            }

            Results = new DbProfilingResults { Query = query };
            _stopWatch.Start();
        }