首先使用EF 4代码如何将对象映射到视图? [英] How map objects to a view with EF 4 code first?

查看:127
本文介绍了首先使用EF 4代码如何将对象映射到视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有办法通过从EntityConfiguration类派生来实现? p>

解决方案

是的!
我找到答案:


你一定可以使用Code First to
映射到一个视图,只需告诉代码首先
表示它是一个表,它将使用
相同的SQL对于
将用于表的视图。显然,如果您的
视图不可写,那么如果您在视图中基于
的实体中尝试更新
值,则
将失败,但是我们只会将
委托给数据库,所以如果您不更新
这些实体,那么您不会有任何
问题。



http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/f154595c-717e-4703-a81d-ee63633a481e


How can you map an entity to a database view with EF 4 code first?

Is there a way to do this by deriving from the EntityConfiguration classes?

解决方案

Yes! I found the answer:

You can certainly use Code First to map to a view, just tell Code First that it's a table and it will use the same SQL against the view that it would for a table. Obviously if your view isn't writeable then saving is going to fail if you try and update values in the entities that are based on the view, but we will just delegate to the database so if you don't update these entities then you won't have any issues.

http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/f154595c-717e-4703-a81d-ee63633a481e

这篇关于首先使用EF 4代码如何将对象映射到视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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