我在 DbContext 中看不到带有 POCO 类的存储过程

发布于 2024-10-17 19:33:13 字数 1484 浏览 2 评论 0原文

为什么我看不到 DbContext 中添加的存储过程? DbContext 由 CTP5 版本(带有 POCO 类)引入的模板生成。

我按照本教程所述添加了存储过程: http ://thedatafarm.com/blog/data-access/checking-out-one-of-the-new-stored-procedure-features-in-ef4/

此外,我搜索了该条目是否添加到我的上下文中这些是结果:

<Function Name="GetClientsForEmailSend" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />

<FunctionImport Name="GetClientsForEmailSend" EntitySet="Client" ReturnType="Collection(DBMailMarketingModel.Client)" />

<FunctionImportMapping FunctionImportName="GetClientsForEmailSend" FunctionName="DBMailMarketingModel.Store.GetClientsForEmailSend">

类似的问题是:

为什么 EF4 不会生成支持我的函数导入的方法?

但我已经完成了所有建议。

这是存储过程:

ALTER PROCEDURE GetClientsForEmailSend
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT OFF;

-- Insert statements for procedure here
SELECT *
FROM dbo.Client AS c
INNER JOIN Subscription AS i on c.IDClient = i.IDClient
WHERE c.Email is not null and c.Email <> '' and i.Active = 1
END
GO

我缺少什么?

谢谢

Why I can't see the stored procedure added in my DbContext? The DbContext is generated by the template introduced with the CTP5 release (with POCO classes).

I added the stored procedures as said by this tutorial:
http://thedatafarm.com/blog/data-access/checking-out-one-of-the-new-stored-procedure-features-in-ef4/

Moreover I searched if the entry is added in my context and these are the results:

<Function Name="GetClientsForEmailSend" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />

<FunctionImport Name="GetClientsForEmailSend" EntitySet="Client" ReturnType="Collection(DBMailMarketingModel.Client)" />

<FunctionImportMapping FunctionImportName="GetClientsForEmailSend" FunctionName="DBMailMarketingModel.Store.GetClientsForEmailSend">

A similar question is:

Why won't EF4 generate a method to support my Function Import?

but I've done all the suggests.

This is the stored procedure:

ALTER PROCEDURE GetClientsForEmailSend
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT OFF;

-- Insert statements for procedure here
SELECT *
FROM dbo.Client AS c
INNER JOIN Subscription AS i on c.IDClient = i.IDClient
WHERE c.Email is not null and c.Email <> '' and i.Active = 1
END
GO

What I'm missing?

Thanks

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉梦枕江山 2024-10-24 19:33:13

DbContext 不支持将存储过程映射到方法。您必须使用 context.Database.SqlCommand(...) 或 context.Database.SqlQuery(...) 直接调用过程

DbContext doesn't provide support for mapping stored procedures to methods. You must call procedure directly by using context.Database.SqlCommand(...) or context.Database.SqlQuery(...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文