hey everybody - I had posted a question in the MVC forum and maybe I'm not getting the right answer because maybe it's not an MVC problem
I have entered a row in my action and return the model to the view and the view "sees" that there's another row but the actual data is not there and I am getting an exception
is there a way to refresh the data in memory before going back the the control?
Hi - thanks for the effort! I added the following (and am including my actionresult jsut in case) - still got the same error so I guess it's not the "refreshing of the database idea" - I must be doing something else fundamentally wrong...
I haven't read much about your post but sound like you are dealling with cach rather than actually data. Ctrl + F5 or F5 at run time. And see what will happen.
Because you work with cassini not IIS. That is a problem of MVC.
GeeksGoneBad
Member
129 Points
57 Posts
Refreshing Data
Feb 20, 2012 05:23 PM|LINK
hey everybody - I had posted a question in the MVC forum and maybe I'm not getting the right answer because maybe it's not an MVC problem
I have entered a row in my action and return the model to the view and the view "sees" that there's another row but the actual data is not there and I am getting an exception
is there a way to refresh the data in memory before going back the the control?
for reference and the whole story - please see http://forums.asp.net/t/1770869.aspx/1?Problem+after+adding+row+not+refreshing+
thanks!
mhinkle2
Member
564 Points
519 Posts
Re: Refreshing Data
Feb 20, 2012 07:25 PM|LINK
Do a control.DataBind after the update
GeeksGoneBad
Member
129 Points
57 Posts
Re: Refreshing Data
Feb 20, 2012 07:34 PM|LINK
Sorry this is for an MVC app and there's no databound controls
thaicarrot
Contributor
5426 Points
1507 Posts
Re: Refreshing Data
Feb 20, 2012 11:30 PM|LINK
Hi GeeksGoneBad,
There's no refresh existing with EF 4.1+. The Refresh method for update individual entity not the whole.
How to solve.
Convert DbContext to ObjectContex
private ObjectContext objectContext;
private void RefreshExecute()
{
objectContext = ((IObjectContextAdapter)context).ObjectContext;
objectContext.Refresh(RefreshMode.StoreWins, this.context.Entities);
}
Weera
GeeksGoneBad
Member
129 Points
57 Posts
Re: Refreshing Data
Feb 21, 2012 02:13 PM|LINK
Hi - thanks for the effort! I added the following (and am including my actionresult jsut in case) - still got the same error so I guess it's not the "refreshing of the database idea" - I must be doing something else fundamentally wrong...
thaicarrot
Contributor
5426 Points
1507 Posts
Re: Refreshing Data
Feb 21, 2012 04:01 PM|LINK
I haven't read much about your post but sound like you are dealling with cach rather than actually data. Ctrl + F5 or F5 at run time. And see what will happen.
Because you work with cassini not IIS. That is a problem of MVC.
Weera
GeeksGoneBad
Member
129 Points
57 Posts
Re: Refreshing Data
Feb 21, 2012 04:49 PM|LINK
Hi Thanks for the idea - but I published to the webserver and I'm still getting the error
GeeksGoneBad
Member
129 Points
57 Posts
Re: Refreshing Data
Feb 21, 2012 05:07 PM|LINK
Got a suggestion in another thread that solved it
turns out I needed to return a redirectToAction rather that the view
Thanks for all the help!