在实体框架中使用相同的存储过程进行插入和更新 [英] Using Same Stored Procedure for Both Insert and Update in Entity Framework
问题描述
我将首先尝试,在XML编辑器中打开EDMX,并在StorageModel元素中找到sproc(Function),复制它,给它一个新的名称。
然后,您可以将一个实际存储过程映射一次,因为插入修改功能一次作为更新修改功能。
我没有实际尝试过,但我可以不明白为什么这不行。
希望这有帮助
亚历克斯詹姆斯,微软计划经理
I have a stored procedure that does both the insert and the update in one fell swoop (if the id == 0 then it's an insert, otherwise, update). I'd love to use this for both the insert and the update methods in Entity Framework, but this isn't looking feasible. Am I correct that I'll have to split the methods into two different stored procedures, or is there a way around this?
On way I would try first, is opening the EDMX in the XML editor and finding the sproc (Function) in the StorageModel element, copy it, giving it a new name.
Then you can map one actual stored procedure twice once as the Insert Modification function once as the Update Modification function.
I haven't actually tried this, but I can't see why this won't work.
Hope this helps
Alex James, Program Manager, Microsoft
这篇关于在实体框架中使用相同的存储过程进行插入和更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!