实体框架VS企业库 [英] Entity framework vs enterprise library

查看:119
本文介绍了实体框架VS企业库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个asp.net项目的客户端远程给我访问数据库。

I am working on a asp.net project the client has given me access to a database remotely.

该数据库具有两个用户。一个用户已经阅读时,其它人有业主只能访问权限。客户说,对于读取数据的目的,我们应该使用第一个和插入等使用第二个。

The database has two users. One user has read only access where as other one has owner access. The client says that for read data purposes we should use the first one and for insertion etc use the second one.

另外,客户告诉我要尽可能多地使用存储过程,因为有很多会从数据库服务器来的数据​​。我想用实体框架(EDMX)。我可以用它存储过程?实体框架之前,我一直在使用企业库存储过程。我需要回去和存储过程中使用它,这样所有的数据库相关的工作是在DB服务器到底做了些什么使用实体框架,使数据的Web服务器,而不是?

Also the client told me to use stored procedures as much as possible because there is lot of data that will be coming from db server. I want to use Entity framework(edmx). Can I use stored procedures with it? Before Entity framework, I have been using Enterprise library for stored procedures. Do I need to go back and use it with stored procedures so that all database related work is done on db server end instead of bringing data to web server using entity framework ?

另外,我怎么可以用一个用户为只读的目的和其他用户访问同一个数据库插入?我需要创建两个网站CONFIGS?这会让区别为只读用户更快获得结果?

Also, how can I use one user for read only purposes and other user to access same db for insertion? Do I need to create two web configs? Does it make difference to make a user read only and get results faster ?

如果有更好的方法,那么请给我建议。

If there is better approach then please suggest me.

请建议。

推荐答案

您可以使用存储过程与EF。但要注意,这是真的很难做实体存储过程。

You can employ stored procedures with EF. But beware, it is really hard to make entities work with stored procedures.

EF生成的查询,而无需编写SQL语句时,它产生通过观察实体变化的SQL语句。它只是你的映射实体数据库表。所以,如果你有表名为项它创建于code面对象项。您可以使用code manuplate项实体,并呼吁EF的相关方法,以反映在实体做数据库的变化。

EF generates queries without writing sql statements, it generates sql statements by observing changes in the entities. It just maps your entities to db tables. So if you have table named "Item" it creates an object "Item" on code side. You can manuplate "Item" entity using code and call related methods of EF to reflect changes done in the entity to the DB.

您可以动态创建连接字符串取决于行动。

You can create the connection string dynamically depending on the action.

问题太广,所以我不知道这是否会有所帮助。

The question is too broad so I do not know whether this helps.

这篇关于实体框架VS企业库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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