我在“仅代码”模式中使用了实体框架CTP5.对于从数据库返回的对象,我正在运行一个LINQ查询,因为查询运行速度非常慢.有什么办法可以得到从查询生成的sql语句?
Topic currentTopic = (from x in Repository.Topics let isCurrent = (x.StoppedAt <= x.StartedAt || (x.StartedAt >= currentTopicsStartedAtOrAfter)) where x.Meeting.Manager.User.Id == user.Id && isCurrent orderby x.StartedAt descending select x).FirstOrDefault();@H_403_4@“Repository”属性是DbContext的后代. @H_403_4@这有点复杂,因为EF不能在对象上使用我的帮助方法,所以我直接在查询中指定逻辑. @H_403_4@那么,有没有什么办法可以转储由LINQ查询生成的sql(例如到我的log4net存储库)?