locked
Please help EF 4.1 how to use Reload method or convert to ObjectQuery or MergeOption? RRS feed

  • Question

  • Hi,

     

    Reloads the entity from the database overwriting any property values with values from the database. The entity will be in the Unchanged state after calling this method.

    Namespace:    System.Data.Entity.Infrastructure
    Assembly:   EntityFramework (in EntityFramework.dll)

     

    public void Reload()

     

    Confused?

    Tuesday, August 30, 2011 10:07 AM

Answers

  • Closed.

    Wednesday, August 31, 2011 6:10 AM
  • Hi,

    DbContext does not provide any Refresh or Merges option and Reload is use with object not DbSet.

    After dig deep in EF 4.1 I was found it is very useful. Here is the code. How to solved.

                objectContext = ((IObjectContextAdapter)context).ObjectContext;
                foreach (var item in this.context.Initials.Local)
                {
                    System.Windows.MessageBox.Show(item.InitialName);
                }
                objectContext.Refresh(RefreshMode.ClientWins, this.context.Initials);

     

    Alternative this.context.Initials this line hit database too.

    Friday, September 2, 2011 4:13 AM

All replies

  • Closed.

    Wednesday, August 31, 2011 6:10 AM
  • Hi,

    DbContext does not provide any Refresh or Merges option and Reload is use with object not DbSet.

    After dig deep in EF 4.1 I was found it is very useful. Here is the code. How to solved.

                objectContext = ((IObjectContextAdapter)context).ObjectContext;
                foreach (var item in this.context.Initials.Local)
                {
                    System.Windows.MessageBox.Show(item.InitialName);
                }
                objectContext.Refresh(RefreshMode.ClientWins, this.context.Initials);

     

    Alternative this.context.Initials this line hit database too.

    Friday, September 2, 2011 4:13 AM