为什么我的数据库上下文中不存在ObjectStateManager属性? [英] Why does the ObjectStateManager property not exist in my db context?

查看:99
本文介绍了为什么我的数据库上下文中不存在ObjectStateManager属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的数据库上下文中返回一个新增的对象列表。

I need to return a list of newly added objects from my database context.

我已经看到,我必须使用 ObjectStateManager 为此目的。问题是,我的数据库上下文没有 ObjectStateManager 属性。

I have read that i have to use ObjectStateManager for this purpos. The problem is, that my database context does not have the ObjectStateManager property.

上下文适用于重新审视,添加和更新对象。

The context works fine for retrivieing, adding and updating objects though.

我使用的是EF 5.0



I am using EF 5.0

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

我可以做什么?

推荐答案

尝试这样:

var manager = ((IObjectContextAdapter)dbContext).ObjectContext.ObjectStateManager;

这篇关于为什么我的数据库上下文中不存在ObjectStateManager属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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