Get TraceString for your business objects in the Entity Framework
问题 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(); 回答1: Different answer for different problem. You can't call ToTraceString() on this: var product = _context.Products.Where( p => p.Category == "Windows" ) .SingleOrDefault(); You can do this: var q = _context.Products.Where( p => p.Category == "Windows" ) var ts