在Entity Framework中添加存储过程复杂类型

编程入门 行业动态 更新时间:2024-10-25 08:25:23
本文介绍了在Entity Framework中添加存储过程复杂类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我做了以下工作:

添加一个函数(右键单击存储过程 - > add - > function import->复杂类型 - >获取列信息 - >创建新的复杂类型)

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

  • 但是表和视图的实体类都是创建的,但也不是存储过程。

    任何人都可以在 BusinessAccount.web.g.cs 中给出不是生成实体类的想法?

    更新:

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

    喜欢:

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

    解决方案

    OK - 这是一步一步的方式:

    (1)add你的存储过程到EDMX文件(当你冷杉(2)使用从数据库更新模型并选择存储过程)

    (2)一旦您在模型中存储过程,请使用模型浏览器添加函数导入:

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

    (4)一旦你这样做 - 您现在应该在模型浏览器的概念模型部分中看到存储过程,以及新生成的复杂类型ld也出现在这里:

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

    I did the following:

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

  • 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.

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

    Update :

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

    Like :

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

    解决方案

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

    (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) once you have the stored procedure in your model - use the Model Browser to add a Function Import :

    (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) 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:

    更多推荐

    在Entity Framework中添加存储过程复杂类型

    本文发布于:2023-11-16 16:00:03,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1605739.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:存储过程   类型   Entity   Framework

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!