0
使用Visual Studio 2010,.NET 4作爲控制檯應用程序。Linq to SQL Not Logging?
在using語句結尾處有一個斷點時,Visual Studio將鼠標懸停在「stuff」上時顯示select語句。但是,「stmt1」和「stmt2」都是空的。爲什麼?
謝謝。
控制檯應用程序:
using (var cona = new mydbcontext(connstring))
{
var stuff = from a in cona.testtable select a;
var stmt1 = cona.SqlStatement;
string stmt2 = cona.GetLoggedInformation();
}
和
public partial class mydbcontext : DataContext
{
private StringBuilder bldr = new StringBuilder();
partial void OnCreated()
{
this.CommandTimeout = 120;
this.Log = new StringWriter(bldr);
}
public String GetLoggedInformation()
{
return bldr.ToString();
}
public string SqlStatement
{
get { return this.bldr.ToString(); }
}
}
就是這樣。我沒有足夠的耐心。一旦我有「stuff.ToList()」stmt1填充。謝謝! – Snowy 2011-04-10 15:27:20
我很好奇,爲什麼在我原來的代碼中,懸停在東西上顯示了sql語句;這就像Visual Studio知道跟蹤/字符串編寫器不知道的東西。 – Snowy 2011-04-10 19:05:20