0

im getting this error

enter image description here

but I have no idea why its happening. It stops happening when I restart visual studio, but after a while, it happens again. Its weird, since it happens just right after logging in. It makes me think that I left a connection open or there is something else going on. You guys have any idea of what could it be?

Morgan Soren
  • 563
  • 4
  • 14
  • 33

1 Answers1

0

Hard to tell without knowing your project. But it may have to do with executing code in a setter, which is generally seen as an anti-pattern. (As an aside: the reason for that is that a setter suggests that you only change that little piece of the object's state, without side effects). An improvement would be to loop through ProjectList not sooner than when the ProjectExtensionList is addressed.

If setting the value for ProjectList is part of the materialization of its containing object (DashboardModel) the loop may cause a database read that has to wait for a connection that is involved in reading values for DashboardModels. If you defer the looping until when it is really necessary, at that point in time the DashboardModel object is in its final state and the connection should be available.

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
  • In other words, I should let the setter to only set the value and find a different way to do the looping or the logic that i'm trying to achieve. I'll try that. If I dont get the error during the whole day, then i guess this should be the answer. – Morgan Soren May 14 '12 at 15:08