简体   繁体   中英

Refresh entity framework view result

I have in database a view named vue_demande and I need to get all its rows in my application :

public IEnumerable<vue_demande> GetAllDemandes()
    {
        if ( context == null) context = GetContext();
        return context.Set<vue_demande>().AsNoTracking <vue_demande>().ToList();
    }

When I modify some values of tables of the view, it isn't refreshed!!!

I need to know :

  1. Why this happens?
  2. How can I Get the list of rows of view up to date?

I assume you are modifying values outside of your context. A context will only ask the database for information that it doesn't already have. If you ask a context to get the same information again it'll just use the values it retrieved last time (this saves trips to the server).

To "refresh" just get a new context:

context = GetContext(); //Assuming your GetContext method returns a new context

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM