简体   繁体   English

实体框架中的存储过程

[英]Stored Procedure in Entity Framework

I had added the Stored procedure in my Entity framework and i also imported the functions in the edmx. 我已经在实体框架中添加了存储过程,并且也将功能导入了edmx中。 Is it must to add all the three functions insert, update, and delete functions to a table. 是否必须将所有三个功能插入,更新和删除功能添加到表中。 I had tried with insert alone and also with all, but why can't i get the name of the stored procedure in the connection string. 我曾经尝试过单独使用insert,也尝试使用全部插入,但是为什么我不能在连接字符串中得到存储过程的名称。

Let me know what i done clearly. 让我知道我清楚地做了什么。

  1. I had added the sp 我已经添加了sp
  2. i had imported the functions in the model browser. 我已经在模型浏览器中导入了功能。
  3. i had also mapped the insert, update and delete function to the table with return type only for insert and update. 我还已经将插入,更新和删除功能映射到具有返回类型的表,仅用于插入和更新。 Still i can't get the name of SP in the connection string. 我仍然无法在连接字符串中获得SP的名称。

    Please let me know how could i resolve this issue. 请让我知道如何解决此问题。 Thanks in Advance, Kamal. 在此先感谢Kamal。

Here is a detailed step-by-step explanation of how to import a stored procedure into an entity. 这是有关如何将存储过程导入实体的详细分步说明。 http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/12/17/ado-net-entity-framework-tools-stored-procedures.aspx http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/12/17/ado-net-entity-framework-tools-stored-procedures.aspx

It is not clear what issue you are trying to resolve. 目前尚不清楚您要解决的问题。

Connection strings have nothing to do with stored procedure's names. 连接字符串与存储过程的名称无关。 They are used to store information about connection, which is sent to an sql server instance, when you are about to establish a connection. 它们用于存储有关连接的信息,当您将要建立连接时,该信息将发送到sql服务器实例。

Why do you care about getting a stored procedure's name at runtime in the first place? 您为什么首先关心在运行时获取存储过程的名称? If you are just mapping procedures to insert/update/delete operations, they will be called automatically, when the appropriate operations are triggered. 如果您只是将过程映射为插入/更新/删除操作,则在触发适当的操作时将自动调用它们。

As to the required mappings, as far as i remember, you can map insert operation alone (at least in EF 4.0+), but insert and delete operations should always be mapped together. 至于所需的映射,据我所记得,您可以单独映射插入操作(至少在EF 4.0+中),但是插入和删除操作应始终映射在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM