访问 IQueryable 后面的 DataContext
是否可以访问 IQueryable 后面的 DataContext 对象?
如果是这样,怎么办?
Is it possible to access the DataContext object behind an IQueryable?
If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DataContext 特定于 LINQ to SQL,因此您可能正在谈论 LINQ to SQL 查询?如果是这样,则没有安全的方法来执行此操作 - 您必须求助于黑客,例如使用反射来检索底层 DataQuery 对象的私有“上下文”字段:
DataContext is specific to LINQ to SQL, so presumably you're talking about LINQ to SQL queries? If so, there's no safe way to do this - you have to resort to a hack such as using reflection to retrieve the private "context" field of the underlying DataQuery object: