我正在寻找一种刷新数据库中更改的实体的方法。我要刷新的实体具有 RowVersion [TimeStamp] 属性。我想做的是刷新我所有加载的实体,其中数据库中的 RowVersion 比我加载的实体更大(更年轻)。
这是我的实体类:
public class Template : ICloneable, IDisposable
{
public int Id { get; set; }
public int InternalId { get; set; }
public int Order { get; set; }
public string Group { get; set; }
public string Description { get; set; }
public string Root { get; set; }
public string Owner { get; set; }
[Timestamp]
public byte[] RowVersion { get; set; }
}
到目前为止,我使用此代码刷新我的实体:
Remoting.Context.ObjectContext.RefreshAsync(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, Entities);
现在每个实体都被刷新,如果有很多实体,这可能会导致性能问题。因此我认为只刷新rowversion不同的实体会更好。我怎样才能做到这一点?