如何使用实体框架创建存储过程?
我读过一篇关于实体框架的旧 MSDN 论坛帖子,其中 朱莉·勒曼指出:
wrt 存储过程。这就算了 比你所指的更好。 您不仅可以映射到存储过程(两者 在 EF 和 LINQ to SQL 中)或覆盖 更新/插入/删除方法,但是 在 EF 中,即将有一种能力 直接在中创建存储过程 映射层。不创建它们并添加 将它们放入数据库,但只拥有它们 住在 EDM 里。所以存储过程没有 必须存在于数据库中。
这不是三月的内容,但我 上周看了它的演示,我们将 将其包含在下一个 CTP 中。
我想看看它是如何工作的演示,但跳入如此庞大的框架及其所有文档,并发现如何查看单个功能是非常困难的。据我所知,实体框架不够动态,无法支持我想要的场景(至少目前还不能),但是针对未来版本的 EF 讨论的一些功能可以满足我的需求。目前我正在使用手动查询生成器,因为 EF 的 ORM 功能不符合我的需求,我真的只想要一个很棒的查询生成器以及创建存储过程和序列化参数化查询的能力。
底线:那么实体框架如何“实时”创建存储过程而不先验地存在于数据库中呢?可以定制吗?它如何处理概念层的变化?为什么映射层会拥有这个逻辑?或者 Julie 只是指像 T4 模板这样恶心的东西(恶心!!!)?
I read an old MSDN Forums post about Entity Framework where Julie Lerman stated:
wrt Stored Procedures. This is even
better than what you are referring to.
Not only can you map to sprocs (both
in EF and in LINQ to SQL) or override
the update/insert/delete methods, but
in EF, there is coming a capability to
CREATE stored procedures right in the
mapping layer. Not create them and add
them into the db, but just have them
live in the EDM. So the sproc doesn't
have to exist in the db.This is not in the March bits, but I
saw a demo of it last week and we will
have it in the next CTP.
I want to see a demo of how this works, but it is excruciatingly hard to jump into such a huge framework and all of its documentation, and discover how to look at a single feature. From best as I can tell, Entity Framework is not dynamic enough to support the scenarios I want, at least not yet, but there are features discussed for future versions of EF that fit my needs. For now I am using a hand-rolled query generator, since the ORM features of EF do not fit my needs and I really just want an awesome query generator and the ability to create stored procedures and serialize Parameterized Queries.
Bottom line: So how does Entity Framework create stored procedures "live" without them existing a priori in the database? Is it customizable? How does it handle changes to the conceptual layer? And why would the mapping layer own this logic? Or is Julie just referring to something gross like T4 Templates (YUCK!!!)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
朱莉的帖子似乎有点含糊。如果它不在数据库中,那么它就不是大多数人所知的“存储过程”。我不认为她的意思是生成一个进程;我认为您今天无法做到这一点,而且我知道您在 2007 年也无法做到这一点。2007 年也没有使用 T4。
她可能一直在说话关于 EdmFunction,但很难告诉。她在 Twitter 上非常活跃,所以你可以直接问她的意思。
Julie's post seems a little vague. If it's not in the DB, it's not a "stored proc" as most people know it. I don't think she meant generate a proc; I don't think you can do that today, and I know you couldn't do it in 2007. Nor was T4 in use in 2007.
She may have been talking about EdmFunction, but it's hard to tell. She's pretty active on Twitter, so you could just ask her what she meant.