将LINQ查询的SQL跟踪显示给Entity Framework 3.5的最佳方法?
我正在使用ASP.net和EF 3.5。
Dim dbo As Web.Portal.RBMEntities = New Web.Portal.RBMEntities Dim Query = From RoleAllocations In dbo.RoleAllocations Where RoleAllocations.user_id = _ID And RoleAllocations.expire_date > Today Select RoleAllocations ' Console write the SQL trace???
谢谢!
我只是试图做到这一点:
Dim TraceString As String = TryCast(Query, ObjectQuery).ToTraceString
效果很好,并返回LINQ语句的SQL跟踪。