如何使用 LINQ to Entities 运行 T-SQL 查询?

发布于 2024-12-24 03:34:36 字数 231 浏览 5 评论 0原文

我想执行一些 T-SQL。我想使用现有的 L2E 连接配置,我不想将新的 SqlClient 提供程序连接配置添加到我的 .config 文件中。我该怎么做? ObjectContext 似乎只有从数据映射架构中返回类结果的方法。

我尝试过执行 ObjectContext.Connection.CreateCommand 方法,然后将我的 T-SQL 指定为命令文本,但它失败并显示类似“无法理解您在查询中谈论的实体”之类的消息。

I want to execute some T-SQL. I want to use existing L2E connection configurations, I don't want to add a new SqlClient provider connection configuration to my .config file. How do I do that? ObjectContext seems to have only methods that return results with classes from data mapping schema.

I've tried doing ObjectContext.Connection.CreateCommand method, then specifying my T-SQL as the command text, but it failed with a message that is something like "could not understand what entities you are talking about in your query".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文