On my DBMS, I have two tables having one-to-many relationship (A <- B). At the first running, I retrieved some records of A (including B) like this:
var lst = from a in ctx.As.Include("Bs") select a;
So, everything is ok. But a few minutes later, I want to get them again because they could be changed on other apps.
我试着用
ctx.Refresh(RefreshMode.StoreWins, lst);
When I do that, the only things are refreshed is object from B, not A. Therefore, I must do another step like:
foreach (var a in lst) {
ctx.Refresh(RefreshMode.StoreWins, a.Bs);
}
如果我没有将 Bs
包含在linq 语句中, 那么使用 Load
方法, 而不是 refresh
这里的问题是调用Refresh
或 Load
太多倍,也许会降低性能。 我如何在不打电话这么多的情况下从数据库存储处重新装入它们?
谢谢!