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

属性值

用于编写命令的编写器。

示例

以下示例先在控制台窗口中显示生成的 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 禁用命令日志记录。

适用于