Hi Guys,
1. So in one of my modules I have this:
Code:
    Public Function GetGoal(ByVal requestGoalNumber As Integer) As goal
        Dim requestGoal As New goal
        'requestGoal = (From gn In db.goals
        '                Where gn.goalNumber = requestGoalNumber
        '                Select gn).FirstOrDefault
        requestGoal = db.goals.[Single](Function(u) u.goalNumber = requestGoalNumber)
        If requestGoal IsNot Nothing Then
            Return requestGoal
        Else
            Return Nothing
        End If
    End Function
2. Now in my custom user control I load the object by calling the module function getGoal like this:
Code:
currentGoal = GetGoal(Request.QueryString("gNum"))
3. Next thing I do is in another function in my custom user control I do this:
Code:
            currentGoal.status = "finished"
            currentGoal.completeDate = Today.Date.ToShortDateString
            db.SubmitChanges()
If the code is setup like this it will not update the database, but if I don't restart the website the next time I call
Code:
currentGoal = GetGoal(Request.QueryString("gNum"))
The currentGoal will have the modified values from step 3. Even if I new currentGoal and then set currentGoal to nothing before calling getGoal it will still have the modified values. It doesn't make any sense because GetGoal should be getting those values from the database. Where does it keep the values if it's not on the database and the object has been destroyed and recreated?

If I close the website and then run it it will pull the values from the database.

The strange part about all this is:

If I don't use the module function. If I make the linq call to populate the object in the user control and then update it from the user control currentGoal does have the updated values and the database is updated.


Code:
currentGoal = db.goals.[Single](Function(u) u.goalNumber = Request.QueryString("gNum"))
currentGoal.status = "finished"
currentGoal.completeDate = Today.Date.ToShortDateString
db.SubmitChanges()
currentGoal = db.goals.[Single](Function(u) u.goalNumber = Request.QueryString("gNum"))
Seems really strange why can't I call a module function to populate the object and then update that object in the user control? There's nothing up with the connection strings. It does call the right database.