在实体框架中添加存储过程复杂类型 [英] Adding stored procedures complex types in Entity Framework

查看:39
本文介绍了在实体框架中添加存储过程复杂类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在实体框架中使用一个不返回任何内容的存储过程.

I am trying to use a stored procedure in Entity Framework that returns nothing.

我做了以下事情:

  1. 添加了一个函数(右键存储过程->添加->函数导入->复杂类型->获取列信息->创建新的复杂类型)

  1. Added a function (right click on stored procedure -> add -> function import-> Complex Type -> Get column information -> create New Complex-Type)

我的函数名称:summarySP_Result.构建项目后,实体类不会在Generated_code (BusinessAccount.web.g.cs)

My function name: summarySP_Result. After building the project the entity class is not generated in Generated_code (BusinessAccount.web.g.cs)

但是表和视图的实体类都是创建的,而不是存储过程.

But entity classes for tables and views are all created but nor for stored procedure.

任何人都可以知道为什么它不是在 BusinessAccount.web.g.cs 中生成的实体类?

Can anybody give the idea why it is not generated entity class in BusinessAccount.web.g.cs?

更新:

让我确认在您的 XXXXXX.web.g.cs 类中创建的 ReturnDataFromTemTable_result 实体类.

Let me confirm ReturnDataFromTemTable_result entity class created in your XXXXXX.web.g.cs class.

喜欢:

[DataContract(Namespace="http://schemas.datacontract.org/2004/07/BizFramework.Web.Model")]
public sealed partial class ReturnDataFromTemTable_Result : Entity
{
   -------------------
 }

推荐答案

好的 - 这是执行此操作的分步方法:

OK - here's the step-by-step way of doing this:

(1) 将您的存储过程添加到 EDMX 文件中(当您第一次创建它时,或者稍后使用从数据库更新模型并选择该存储过程)

(1) add your stored procedure to the EDMX file (when you first create it, or later on by using Update model from database and picking that stored procedure)

(2) 一旦你的模型中有存储过程 - 使用 Model Browser 添加一个 Function Import :

(2) once you have the stored procedure in your model - use the Model Browser to add a Function Import :

(3) 弹出的下一个对话框非常重要 - 您需要 (1) 定义存储过程返回复杂类型的集合,然后您需要 (2) 从该存储过程中获取列信息以知道它将返回哪些列,然后 (3) 告诉 Visual Studio 根据该列信息生成一个新的复杂类型:

(3) the next dialog that pops up is vitally important - you need to (1) define that the stored procedure returns a collection of complex types, then you need to (2) get the column info from that stored procedure to know what columns it will return, then (3) you tell Visual Studio to generate a new complex type based on that column info:

(4) 完成后 - 您现在应该在模型浏览器的概念模型部分看到存储过程,并且新生成的复杂类型也应该显示在那里:

(4) once you've done that - you should now see the stored procedure in your conceptual model section in the Model Browser, and the newly generated complex type should show up there, too:

这篇关于在实体框架中添加存储过程复杂类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆