Unanswered DataGrid cache rows

  • Wednesday, January 30, 2013 1:31 PM
     
      Has Code

    Hello,

    my name is Luca form Italy (sorry for my English).

    My problem is: I have a DataGrid that I bind runtime calling a WebService and creating instances of a table

    Table1ProductionLineItem pli = this.DataWorkspace.ApplicationData.TableProductionLine.AddNew();

    ..

    My problem is: when I start the LightSwitch app, I show some row in the datagrid (by calling the WS), then I close the app and restart it:

    the DataGrid show me the last rows..in some manner the DataGrid seems to cache the last data, but the app was stopped!!

    Can someone help me?

     

All Replies

  • Thursday, January 31, 2013 5:09 AM
    Moderator
     
     

    It's not caching the rows, but is saving them to the database. At some point, you are instructing the screen to save the changes before the application shuts down (either through code or through some gesture, like agreeing to save data as a screen closes). So when you start it back up again, the data is loaded from the database.


    Justin Anderson, LightSwitch Development Team

  • Thursday, January 31, 2013 8:39 AM
     
      Has Code

    In effect I use the follow code to apply the deletion

     private void EmptyTableProductionLine()
            {
                // remove all Items form EntitySet
                foreach (Table1ProductionLineItem pli in this.DataWorkspace.ApplicationData.TableProductionLine)
                {
                    pli.Delete();
                }
            }

    ..

    ..

    this.DataWorkspace.ApplicationData.SaveChanges();

    , but Justin I'm not connected with a DataBase, I only use WebServices.

    LigthSwitch saves data in a internal DB?! Is There a way to cancel this data?

    Thanks!!!

  • Thursday, January 31, 2013 8:53 AM
     
     
    I tried also tho use this.Save() instead

    this.DataWorkspace.ApplicationData.SaveChanges(); ,but the result is the same..