简体   繁体   中英

How do I know to refresh my linq queries?

I have a basic grid of Linq2Sql entities (frmList). I have a separate form for editing (frmEdit). frmEdit has its own DataContext (as that appears to be the recommended way). How can I tell when my detail form has saved changes?

I don't see a built-in method. I am considering raising an event on the detail form when I save the datacontex, but not sure how I consume this event on frmList, and I have a feeling these events are already created for me somewhere?

Thanks - as you can probably tell, I am not fully grokking events yet.

Im guessing these are simple windows forms then as you said raise an event like the following:

' Declare an event at module level.
Event EditCompleted()

raise event after the db.SubmitChanges()

' Raise the event.
RaiseEvent EditCompleted()

Listen to these events:

Private WithEvents EditForm as new frmEdit

in this same form (frmList):

Private Sub OnEditCompleted() Handles EditForm.EditCompleted
   'Refresh your frmList
End Sub

Please, correct me if im wrong! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM