实体框架4.1-刷新不是上下文的成员 [英] Entity Framework 4.1 - Refresh is not a member of Context

查看:90
本文介绍了实体框架4.1-刷新不是上下文的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Context.Refresh方法还原Context的更改,但是Refresh似乎不是Context的成员.

I'm trying to revert Context changes using the Context.Refresh method but It seems like Refresh is not a member of Context.

我正在使用Microsoft ADO.NET实体框架4.1 RC版本.

I'm using the Microsoft ADO.NET Entity Framework 4.1 RC version.

有什么主意吗?

推荐答案

您可能正在查看 IObjectContextAdapter 接口以获取基础的ObjectContext,然后在其上调用Refresh.

You are likely looking at a DbContext, which does not have a Refresh method. You can use the IObjectContextAdapter interface to get the underlying ObjectContext, and call Refresh on that.

var objectContext = ((IObjectContextAdapter)context).ObjectContext;

这篇关于实体框架4.1-刷新不是上下文的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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