DataContext.Log 屬性

定義

取得或設定寫入 SQL 查詢或命令的目的。

public:
 property System::IO::TextWriter ^ Log { System::IO::TextWriter ^ get(); void set(System::IO::TextWriter ^ value); };
public System.IO.TextWriter Log { get; set; }
member this.Log : System.IO.TextWriter with get, set
Public Property Log As TextWriter

屬性值

TextWriter

要用於寫入命令的寫入器。

範例

下列範例會在主控台視窗中顯示產生的SQL,再顯示查詢的結果。

db.Log = Console.Out;
var custQuery =
    from cust in db.Customers
    where cust.City == "London"
    select cust;

foreach (var custObj in custQuery)
{
    Console.WriteLine(custObj.ContactName);
}
db.Log = Console.Out
Dim custQuery = _
From cust In db.Customers _
Where cust.City = "London" _
Select cust

For Each custObj In custQuery
    Console.WriteLine(custObj.ContactName)
Next

備註

將此屬性設定為 null ,以停用命令記錄。

適用於