How do I get the trace string for a query like this:
var product = _context.Products.Where( p => p.Category == "Windows" )
.SingleOrDefault();
// I can't do this since product is not an ObjectQuery instance
// product.ToTraceString();
Different answer for different problem.
You can’t call
ToTraceString()on this:You can do this:
… but it’s not 100% accurate. The MSSQL EF provider will use a
TOP 2forSinglewhich this will miss.You can come close with this:
…which should get you the right SQL but requires knowledge of the implementation.
Original question misrepresented the problem. My original answer was: