开发者

EF4 - ChangeObjectState is no longer accessible in RC

After migrated EF4 CTP5 to RC1, I notice the ObjectContext is no longer accessible through DbContext. It means I can't access ChangeObjectState method.

class DataContext : DbContext
{
    public DataContext()
    {
    }

    public DataContext(DbCompiledModel dbModel)
        : base(dbModel)
    {
    }

    public DbSet<MyClass> MyClasses { get; set; }

    public void ChangeObjectState<T>(T entity, EntityState entityState)
    {
        // this is no longer working.. where is ObjectContext? 
        ObjectContext.ChangeObjectState(entity, entityState);
    }
}

Has anyone have any idea how access that method in RC1?

开发者_JAVA百科

Thanks.


You don't need to access ObjectContext to change object state. Use this:

this.Entry<T>(entity).State = entityState;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜