How to Detect Select n+1 problems in Linq to SQL?

家住魔仙堡 提交于 2019-12-01 08:34:48

This won't outright detect n+1 problems, but they're pretty easy to spot when you look at your generated SQL.

The DataContext.Log property takes a TextWriter that will output the generated SQL and some other diagnostic information. Here's an implementation that logs to the output. Linq to SQL DebuggerWriter. Here's the simple example of how to use the DebuggerWriter.

DataContext db = new DataContext();
#if DEBUG
db.Log = new DebuggerWriter();
#endif
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!