如何将选择的存储过程映射到EF 3.5中的实体?

时间:2022-06-10 02:33:10

Maybe I'm missing something here... we are trying to adopt a framework for data access and have been exploring EF3.5.

也许我在这里遗漏了一些东西......我们正在尝试采用数据访问框架,并且一直在探索EF3.5。

Everything we do in our organization is required to be in a stored procedure so the DBA's can have a feeling of control. If I generate my entities from my database schema, I see how to map stored procedures to the update/insert/delete commands of an entity, but there is no mapping for the retrieval of the data.

我们在组织中所做的一切都需要在存储过程中,因此DBA可以有一种控制感。如果我从我的数据库模式生成实体,我会看到如何将存储过程映射到实体的update / insert / delete命令,但是没有用于检索数据的映射。

Is this always internal to the framework, or can we somehow map our retrieval procedures to their respective entities? If it is internal, is it possible to view/modify the generated sql?

这总是内部框架,还是我们可以以某种方式将我们的检索程序映射到它们各自的实体?如果是内部的,是否可以查看/修改生成的sql?

Thanks in advance for your help.

在此先感谢您的帮助。

1 个解决方案

#1


1  

When creating a model you are able to add a stored procedure to it.
In case these stored procedures are returning collections of Entity types they can be added to the model.
Open the model in designer, right-click on the procedure and select the "Create Function Import" option. Specify the correct return type, and you'll get a method retreiving entities.

创建模型时,您可以向其添加存储过程。如果这些存储过程返回实体类型的集合,则可以将它们添加到模型中。在设计器中打开模型,右键单击该过程并选择“创建函数导入”选项。指定正确的返回类型,您将获得一个方法retreiving实体。

#1


1  

When creating a model you are able to add a stored procedure to it.
In case these stored procedures are returning collections of Entity types they can be added to the model.
Open the model in designer, right-click on the procedure and select the "Create Function Import" option. Specify the correct return type, and you'll get a method retreiving entities.

创建模型时,您可以向其添加存储过程。如果这些存储过程返回实体类型的集合,则可以将它们添加到模型中。在设计器中打开模型,右键单击该过程并选择“创建函数导入”选项。指定正确的返回类型,您将获得一个方法retreiving实体。