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 DashboardModel
s. 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.