Print Page | Close Window

Inserted Item not Updating

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2454
Printed Date: 12-May-2026 at 10:39pm


Topic: Inserted Item not Updating
Posted By: yimbot
Subject: Inserted Item not Updating
Date Posted: 20-Jan-2011 at 5:53am
An interesting problem...
 
When first loading a page, I call the GetWidgets Method to and bind the reults as an item source of a combo box. Works fine.
If i then add a widget to the database by any method (even through SQL Management studio) and execute my query again, it does not find the new item added.
 
This is my GetWidgets Method
 
        public void GetWidgets()
        {
                IsBusy = true;
                WidgetsList.Clear();
                var query = Mgr.Widgets.Where(a => a.UserID == CurrentUserID);
                query.ExecuteAsync(op =>
                                       {
                                           if (op.HasError)
                                           {
                                               MessageBoxServiceProvider.ShowError("Unable to retrive your Widgets",
                                                                                   "Widget Error");
                                               op.MarkErrorAsHandled();
                                           }
                                           else
                                           {
                                               op.Results.ForEach(WidgetsList.Add);
                                           }
                                           IsBusy = false;
                                       });
            }



Replies:
Posted By: yimbot
Date Posted: 22-Jan-2011 at 3:25pm
Any ideas or suggestions as to where this might be failing?


Posted By: kimj
Date Posted: 22-Jan-2011 at 9:05pm
Has the em.DefaultQueryStrategy been set to CacheOnly?


Posted By: smi-mark
Date Posted: 23-Jan-2011 at 11:15am
If you always want to go back to the SQL Server for this query, try changing:
var query = Mgr.Widgets.Where(a => a.UserID == CurrentUserID);

to

var query = Mgr.Widgets.Where(a => a.UserID == CurrentUserID).With(QueryStrategy.DataSourceOnly);



Posted By: kimj
Date Posted: 24-Jan-2011 at 12:34pm
I should have added that when QueryStrategy.Normal is used, if a query has been seen before DevForce will assume that the next time the query is run it can be satisfied entirely from cache.  smi-mark is correct that to override this behavior you can use QueryStrategy.DataSourceOnly.  Here's more information on the subject - http://drc.ideablade.com/xwiki/bin/view/Documentation/EntityCaching - http://drc.ideablade.com/xwiki/bin/view/Documentation/EntityCaching .


Posted By: yimbot
Date Posted: 25-Jan-2011 at 5:40am
Great info. Thanks for your replies!



Print Page | Close Window