user2130865
user2130865

Reputation:

Entityframework ObjectContext Refresh changed Entities

i am looking for a way of refreshing Entities that changed in the Database. The Entities i want to refresh have a RowVersion [TimeStamp] Property. What i wanna do is refresh all my loaded Entities where the RowVersion in the database is greater (younger) than my loaded entities.

Here my entity class:

 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; }

}

So far i use this code to refresh my entities:

Remoting.Context.ObjectContext.RefreshAsync(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, Entities);

Right now every entity is refreshed which maybe causes performance issues if there are many of them. Therefore i thought it would be better to only refresh the entities where the rowversion is different. How can i do that?

Upvotes: 0

Views: 142

Answers (0)

Related Questions