如果是在桌面程序中
_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="C#" AutoEventWireup="true" CodeBehind="Log.aspx.cs" Inherits="Clowwindy.Log" %>
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/11979.html