This is a migrated thread and some comments may be shown as answers.

[Solved] Is there a way to notify an object that it is going to be saved?

1 Answer 49 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David Ribb
Top achievements
Rank 1
David Ribb asked on 24 Nov 2010, 12:45 PM
Is there a way to notify an object that it is going to be saved?  When I call context.SaveChanges(), I need a way for each one of my changed objects to know that it's about to be saved so it can preform some tasks.

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 25 Nov 2010, 07:44 PM
Hello David Ribb,

You could achieve this goal by using the ITracking interface’s events. Helpful information regarding how to do that can be found here.
But firstly you should expose the underlying IObjectScope instance in a partial class of your generated context class:

public partial class YourContextNameHere
{
    public IObjectScope Scope
    {
        get
        {
            return this.GetScope();
        }
    }
}

Hope that helps.

Sincerely yours,
Damyan Bogoev
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
General Discussions
Asked by
David Ribb
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or