小编Dav*_*ave的帖子

代码优先 - 当我没有将父对象设置为EntityState.Modified时,如何保存ICollection?

如果我有以下课程:

public class Foo()
{
public int PropertyIWantUpdated {get; set;}
public int PropertyIDontWantUpdated (get; set}

public ICollection<Bar> Bars {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

保存到我的数据库时,而不是

context.Entry(thisFoo).State = EntityState.Modified;
Run Code Online (Sandbox Code Playgroud)

我正在使用

context.Entry(thisFood).Property(tf => tf.PropertyIWantUpdated).IsModified = true;
Run Code Online (Sandbox Code Playgroud)

如何保存对Bars的更改?

entity-framework ef-code-first entity-framework-ctp5 entity-framework-4.1

4
推荐指数
1
解决办法
1427
查看次数