[英]Using EntityDataSource in “Tracing and Caching for Entity Framework”
I am using Tracing and Caching for Entity Framework in my asp.net 4 application. 我在asp.net 4应用程序中使用了实体框架的跟踪和缓存 。 It works great when I work on my entities manually, but in master-detail pages that have a gridview and an entitydatasource, I cannot make entitydatasource use the global cache because I have no control over creating objectcontext and entitydatasource does all the work by itself.
当我手动处理实体时,它的效果很好,但是在具有Gridview和EntityDataSource的主从页面中,由于无法控制创建objectcontext的权限,因此我无法使EntityDataSource使用全局缓存,而EntityDataSource本身可以完成所有工作。
My question is: is there a way to customize entitydatasource for initializing the object context and things like that and if not how can i use and objectdatasource with entity faramework. 我的问题是:有没有一种方法可以自定义entitydatasource来初始化对象上下文和类似的东西,如果没有的话,我该如何使用objectfaramework和objectdatasource。
Yes there is a way. 是的,有办法。
EntityDataSource
offers event ContextCreating
. EntityDataSource
提供事件ContextCreating
。 If you handle this event you will be able to initialize context yourselves and pass it to data source via event's arguments. 如果处理此事件,您将能够自行初始化上下文并将其通过事件的参数传递给数据源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.