映射实体框架中的存储过程 [英] Mapping Stored Procedure in Entity Framework

查看:81
本文介绍了映射实体框架中的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有办法为Entity Framework中的所有(插入,更新,删除)操作映射单个存储过程。据我搜索,我找到了为每个操作绘制单个程序的方法。但我有一个过程插入,更新和删除选项。请帮助完成这项任务。

感谢U所有

Hi,
Is there any way to map single stored procedure for all (insert, update, delete) operations in Entity Framework. As far as i searched i found the ways of mapping individual proceures for each operation. But i have one procedure that does insert, update and delte with options. Pls help to accompish this task.
Thank U All

推荐答案

有一个完成所有操作的过程,是一个愚蠢的设计。它意味着传递一个参数来告诉它该做什么,并且在编辑它的时候,为一项任务提供了比你需要的代码更多的代码。



但是,当您映射到EF中的proc时,您没有定义它所做的事情,您只需将其公开为您调用的内容。所以,我认为你在谈论一个(也是荒谬的)ASP.NET控件,你告诉它为CRUD调用什么方法。你最好采取比这更好的控制,如果你这样做,如果你必须,可以在所有实例中调用相同的proc,并传入一个参数来告诉它你想要的操作。



我仍​​然认为你最好只使用一个proc / one任务。
Having one process that does it all, is a dumb design. It means passing in a parameter to tell it what to do, and having a lot more code than you need, in terms of when you edit it, for one task.

However, when you map to a proc in EF, you don't define what it DOES, you simply expose it as something you call. So, I think you're talking about one of the ( also ridiculous ) ASP.NET controls which you tell what methods to call for CRUD. You're better off taking more control than that, and if you do, if you must, can call the same proc in all instances, and pass in a parameter to tell it which operation you want.

I still think you're better off with one proc/one task though.


这篇关于映射实体框架中的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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