EF&存储过程中有额外的参数 [英] EF & Stored Procs with extra parameters

查看:50
本文介绍了EF&存储过程中有额外的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



背景:我有存储过程来执行INSERT,UPDATE和DELETE。这些过程包括必要的参数(包含在表中)以及用于事件记录的一些额外参数(未包含在表中)。

我试图使用实体数据模型设计器来映射这些程序到相关表格(在.edmx中)。


试图映射例如INSERT程序我无法映射额外参数,因为它们不在表中,因此产生错误(2037)

我试图通过手动添加标量属性来解决这个问题,但这又产生了一个新的错误(11009),说明属性没有映射。


我对实体框架还很陌生,非常感谢有关此事的任何意见或建议。

提前致谢:)

Hi,

Background: I have stored procedures to perform INSERT, UPDATE and DELETE. These procedures include the necessary parameters (contained in the table) as well as some extra parameters (not contained in the table) used for event logging.

I am trying to use the Entity Data Model Designer to map these procedures to the relevant tables (in the .edmx).


Trying to map for example the INSERT procedure I am unable to map the extra parameters considering they are not present in the table, thus producing an error (2037)

I tried to solve this problem by manually adding a scalar property, but that in turn produces a new error (11009) stating the property is not mapped.


I am still very new to the Entity Framework and would really appreciate any advice or suggestions on this matter.


Thanks in advance :)

推荐答案

很抱歉,但这是无法实现的。
这是Julia Lerman的书的引用我希望它能清除你试图做的事情:
" ;将函数映射到实体有一些严格的规则:


全部或全部

Hi,
Sorry but this can't be achieved.
This is a quote from Julia Lerman's book I hope it will clear the things you try to do:
"There are some strict rules for mapping functions to entities:

All or nothing

您必须映射所有三个函数或不映射它们。这是基于实体框架如何使用这些映射的要求。 Visual Studio将显示错误(错误2025),该错误显示"映射架构的架构验证失败"。错误详细说明了映射不完整,甚至会告诉您缺少三个函数映射中的哪一个。

You must map either all three functions or none of them. This is a requirement based on how the Entity Framework works with these mappings. Visual Studio will display an error (Error 2025) that reads "The schema validation failed for mapping schema". The error details explain that the mapping is incomplete and will even tell you which of the three function mappings is missing.

没有随机输入或输出参数

No random input or output parameters

函数的每个输入参数都必须与实体中的属性对齐。您无法替换自己的数据来用作输入参数。您只能使用实体的某个属性。

Every input parameter of a function must line up with a property in the entity. You can't substitute your own data to use as an input parameter. You only can use one of the entity's properties.

的关联 EntityReference 需要所有三个函数的输入参数

本章我们不会关注此规则。但是,如果您将功能映射到地址 ,则必须对联系导航属性。您将在下一章中看到这一点。"

We won't focus on this rule in this chapter. However, if you were mapping functions to the Address, you would have to make some special considerations with respect to the Contact navigation property. You'll see this in action in the next chapter."


这篇关于EF&存储过程中有额外的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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