本文介绍了手动在edmx文件中添加存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在edmx文件中持久添加手动添加的存储过程?数据库是根据模型生成的.每次我在edmx文件的编辑器中进行更改时,存储过程都会丢失.之后,仅 FunctionImport 条目仍然可用.

Is it possible to persistently add the manually added stored procedures in the edmx file? The database is generated from model. Every time I change something within the editor in the edmx file, the stored procedures are lost. Only the FunctionImport entry is still available afterwards.

一个示例 Function 看起来像这样:

A sample Function looks like this:

<Function Name="SP_I_InsertGroup" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
    <Parameter Name="name" Type="nvarchar" Mode="In" />
    <Parameter Name="chiefId" Type="int" Mode="In" />
    <Parameter Name="description" Type="nvarchar" Mode="In" />
    <Parameter Name="parentId" Type="int" Mode="In" />
    <Parameter Name="mode" Type="char" Mode="In" />
</Function>

相应的 FunctionImportMapping :

<FunctionImportMapping FunctionImportName="InsertGroup" FunctionName="DAL.Store.SP_I_InsertGroup" />

FunctionImport :

<FunctionImport Name="InsertGroup" ReturnType="Collection(Int32)">
    <Parameter Name="name" Mode="In" Type="String" />
    <Parameter Name="chiefId" Mode="In" Type="Int32" />
    <Parameter Name="description" Mode="In" Type="String" />
    <Parameter Name="parentId" Mode="In" Type="Int32" />
    <Parameter Name="mode" Mode="In" Type="String" />
</FunctionImport>

推荐答案

Moo,您不应该手工修改edmx文件.

Moo, you should not modify the edmx file by hand.

对此文件所做的更改可能会导致错误的行为,并且如果重新生成代码,将会丢失这些信息."

"Changes to this file may cause incorrect behavior and will be lost if the code is regenerated."

这就是为什么您失去工作的原因.您应该使用与设计表相同的方式映射设计者已经创建的存储过程.

That´s why you´re losing your work. You should map the already created stored procedure from the designer, the same way you made with your tables.

我假设您正在使用EF4.

I´m assuming you´re playing with EF4.

这篇关于手动在edmx文件中添加存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 05:33