MVC.NET or LINQ

Last post 02-01-2009 3:55 PM by Luis Abreu. 5 replies.

Sort Posts:

  • MVC.NET or LINQ

    01-31-2009, 11:16 PM
    • Member
      143 point Member
    • jwize
    • Member since 10-13-2005, 1:42 AM
    • Posts 123

    I am having a little difficult with my index view not updating the changes in my data. My code just takes an object that it pulls out of the database by id and then does an update on it. Once the update is complete the pages is redirected back to the index view where you can see the list of entities in a grid. The problem is that hte data in the list is not loading from the database anymore. The database reflects the changed values properly but I can't find any way to update the data that is being passed as a datasource. Using a visualizer I can see clearly that the query is returning the correct set of data.

     Is this something to do with caching in the mvc framework or linq to sql or could there be some other reason for this?

  • Re: MVC.NET or LINQ

    02-01-2009, 5:27 AM
    • Member
      143 point Member
    • jwize
    • Member since 10-13-2005, 1:42 AM
    • Posts 123

    Fixed it but still unsure of the behavior. I built a service class in  which planted a static variable with the datacontext object. I guess it the static context object survived through form posts there for when I queried the object from the database to make the update I somehow sidestepped that context object updating the database but not synchronizing the data that was populated the index view's list of items. What appeared to be a bug in the framework was just injected by myself. Isn't that always the case!

  • Re: MVC.NET or LINQ

    02-01-2009, 10:13 AM
    • Member
      126 point Member
    • deerchao
    • Member since 08-22-2005, 4:22 PM
    • Posts 39

     Well, I hope that's always the case, but they keep releasing CTP, Beta, RC, RTM, SP to make me doubt myself :)

    My blog (zh-CN)
    Be and awear of who you are.
  • Re: MVC.NET or LINQ

    02-01-2009, 10:46 AM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    Hello.

    hum...not sure on what you're saying here...static objects are alive while the process that "hosts" them lives. Their use isn't really recommended in most scenarios, but I think that form posts won't influence its life.

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: MVC.NET or LINQ

    02-01-2009, 2:43 PM
    • Member
      143 point Member
    • jwize
    • Member since 10-13-2005, 1:42 AM
    • Posts 123

    Hey there, 

    hum...not sure on what you're saying here...static objects are alive while the process that "hosts" them lives. Their use isn't really recommended in most scenarios, but I think that form posts won't influence its life.

    My intention was not to keep anything alive. For whatever reason my datasource was a static instance of object and the query must have not run because no changes were detected to the data. Therefore, my data was displaying in its original value and was causing the problem. I was just outlining the problem so that if someone else created a static object and expected it not to live through "post backs"--If I can call it that--they might run into the same problem. After tesing more and changing to instance objects the problem went away.  No harm in trying things!

    But the important point as you mentioned is that if my objects are created as static then they live as long as the process is alive? Just to be clear, not the AppDomain only?

     

  • Re: MVC.NET or LINQ

    02-01-2009, 3:55 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    Hello again.

    I was only trying to point out that static variables will survive form posts. And yes, you're absolutely right: their timelife is limited to the AppDomain where they live.

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
Page 1 of 1 (6 items)