开发者

EF4 - ChangeObjectState is no longer accessible in RC

开发者 https://www.devze.com 2023-02-20 06:13 出处:网络
After migrated EF4 CTP5 to RC1, I notice the ObjectContext is no longer accessible through DbContext. It means I can\'t access ChangeObjectState method.

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

精彩评论

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