如果是在桌面程序中
_context
即可在控制台輸出SQL語句
這時我想起了StringWriter
於是構造一個輔助類
using System;
using System
using System
using System
using System
using System
namespace Clowwindy
{
public static class LogHelper
{
public static StringBuilder Log = new StringBuilder();
public static TextWriter In = new StringWriter(Log);
public static string GetAllLog()
{
In
return Log
}
public static void Clean()
{
Log = new StringBuilder();
In = new StringWriter(Log);
}
}
}
再添加一個頁面log
<%@ Page Language=
CodeBehind=
<!DOCTYPE html PUBLIC
<html xmlns=
<head runat=
<title>SQL Log</title>
</head>
<body>
<form id=
<asp:Button ID=
onclick=
<div>
<asp:Literal ID=
</div>
</form>
</body>
</html>
using System;
using System
using System
using System
using System
using System
using Clowwindy
namespace Clowwindy
{
public partial class Log : System
{
protected void Page_Load(object sender
{
if (Request
{
Response
return;
}
Literal
}
protected void btn_Clean_Click(object sender
{
LogHelper
Literal
}
}
}
最後在所有new DataContext的地方
加上_context
public Repository()
{
_context = new TDataContext();
_context
}
打開log
From:http://tw.wingwit.com/Article/program/net/201311/13540.html