使用实体框架(EF)时如何查找通过ODAC发送到Oracle数据库的查询

时间:2011-11-16 23:08:26

标签: .net oracle entity-framework odac

我正在使用Oracle ODAC for EntityFramework。我正在尝试使用entityframework开发一个示例silverlight应用程序。我添加了我的域名服务,我通过该域名服务发布我的实体。我是UI的代码隐藏文件。我写了以下代码。

var threemonthsold = DateTime.Now.AddMonths(-3);
var query = serverContext.GetSR_MERGED_DATAQuery().Where(t => t.SR_DATE_RECD > threemonthsold);

var regionLoadOp = serverContext.Load(query);
dataGrid.ItemsSource = regionLoadOp.Entities; 

我想知道哪些查询已发送到oracle。由于操作正在超时,应用程序崩溃。看起来查询需要很长时间。如果我能找到查询,我可以直接在oracle上运行它,并找出它在那里花了多长时间。

任何帮助都非常感激。

由于

2 个答案:

答案 0 :(得分:1)

如果您通过网络发送查询,Wireshark是查看正在传输的实际数据包的绝佳方式。如果为数据包过滤器键入TNS(不是捕获过滤器,而是主页上的那个,并在无效/有效输入上变为红/绿),则可以看到Oracle数据包。

Screenshot of oracle packet in wireshark found using <code>tns</code> filter and Find Packet searching for the string 'select' in the packet's bytes.

似乎有no maintained packet dissector来显示数据包的不同部分,但您可以查看数据字节并查看显示SQL语句的ASCII文本。 (你还会看到一堆会话打开/关闭垃圾。)

答案 1 :(得分:0)

following forum.中找到了这个问题的答案:

cshay Dec 3, 2011 9:58 AM (in response to 900653)
You can turn on ODP.NET tracing. See the ODP.NET doc for more details:

1) Close VS
2) In windows registry, change registry value 
    \\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ODP.NET\4..........\TraceLevel
    to 1
3) Relaunch VS
4) Reproduce the problem
5) Close VS2010
6) Look for the odpnet trace file in the root of C I believe.
7) Undo the registry value (set it back to 0) so you don't impact performance