views:

25

answers:

1

Hi. I have a silverlight 4 ria app, and I'd like to fire an event after entities have been submitted to the database. I thought that I could use the dataclassescontext methods like

OnCreated() OnIdChanged()

but they are called before submitted, and I only want to fire the event once a new entity is added to the db, and once an id change has been submitted.

+1  A: 

You can use override methods called “InsertX”, “UpdateX” and “DeleteX” in your dataclassescontext, where “X” is the name of the table.

For example, if your entity table is called Users, the methods are called partial void InsertUser(User instance) etc. These methods are called during the SubmitChanges() stage, and the “standard” Insert/Delete/Update is only performed if such an override method is not present.

There are several things you need to be aware of when writing these Insert/Update/Delete override methods. Those are documented here on MSDN: Responsibilities of the Developer In Overriding Default Behavior (LINQ to SQL)

Timwi
So that's what I misunderstood :) You are AWESOME!
Jakob
Thanks :) —————
Timwi