我在 DbContext 中看不到带有 POCO 类的存储过程
为什么我看不到 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">
类似的问题是:
但我已经完成了所有建议。
这是存储过程:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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(...)