locked
SaveChangesAsync() is not working properly.

    Question

  • Hi,

       I am working in window 8 app. I am using sqlite datbase in it. I am trying to update the value in database. But the SaveChangeAsync() method is taking time to update. When I am debugging the code and waiting for some seconds after SaveChangesAsync() method, value changes in database successfully, but if I don't wait then its not updating in database. And without debugging its not updating in tables also.

     Any one knows what will be the problem? 

    following is the code in which in my stuck:

    foreach (Project proj in db.GetAll<Item>().Where(p => p.UpdatedOn > p.LastSyncOn || (p.UpdatedOn != null && p.LastSyncOn == null)).ToList())
                    {
                        
                        TransProjectData data = proj.SendDataToTrans();
                        
                        proj.LastSyncOn = DateTime.UtcNow;
                        proj.LockedOn = DateTime.UtcNow;
                        db.Update<Project>(proj);

                        await db.SaveChangesAsync();

    }

    Thursday, January 15, 2015 6:09 AM

Answers

  • Hi Anand,

    To narrow down the issue, I would suggest you test with a really simple data instead of using foreach and Linq, or set a timestamp to see which step cause the biggest time.

    Besides you mentioned without debugging the data is not updating, that's really interesting, would you tell me which SQLite connection API you are using and which extension are you using.

    Anyway I would suggest you to use Visual Studio diagnose tool to see where exactly spend too much time.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, January 16, 2015 3:18 AM
    Moderator