Gets a value indicating the update method performed or to be performed for the specified persistent object since the last executed update batch in the current logical transaction of the Context.
A value indicating the update method performed or to be performed for the specified persistent object since the last executed update batch in the logical transaction of the Context.
The value of the UpdateEvent property indicates the type of changes performed on the specified persistent object since it was last synchronized with its corresponding DataDomain when executing the previous update batch. Persistent objects created since the execution of the last update batch are marked with UpdateEvents.Insert even if the object was modified (but not committed) after the creation. Persistent objects deleted since the execution of the last update batch are marked with UpdateEvents.Delete. If the state of the persistent objects was changed since the execution of the last update batch it is marked with UpdateEvents.Update even if it was created in the scope of the current logical transaction.
The values of the CommitEventArgs.UpdateEvent and the UpdateEvent properties are not necessarily equal for the same persistent object within the same logical transaction. The value of the CommitEventArgs.UpdateEvent indicates the overall accumulative changes performed on the persistent object within the entire logical transaction whereas the value of UpdateEvent indicates local changes performed on the persistent object since the last update batch.
class EventTest
{
public static void Update(object sender, UpdateEventArgs args)
{
Console.WriteLine("{0} update performed", args.UpdateEvents);
}
public static void Commit(object sender, CommitEventArgs args)
{
if( args.CommitResult == CommitResults.Committed )
Console.WriteLine("The transaction has been committed successfully." +
" Update performed: {0}", args.UpdateEvent);
}
public static void Main()
{
using(Context.Push(ShortRunningTransactionContext.Create()))
{
Context.Current.AfterUpdateObject += new UpdateEventHandler(EventTest.Update);
Context.Current.AfterCommitObject += new CommitEventHandler(EventTest.Commit);
Person cain = DB.New(typeof(Person), "Cain");
cain.Age = 35;
// the execution of the following query would force <macro name="DAL" /> to execute an update batch
// to synchronize pending changes; 'cain' would be committed to the database
Person adam = (Person)DB.Extent(typeof(Person))["Name={0}", "Adam"].ToObject();
cain.Father = adam;
// committing the logical transaction will force another update batch to execute
// as further changes have been performed since the last update batch
Context.CommitCurrent();
}
} The output of the above code is:
INSERT update performed UPDATE update performed The transaction has been committed succesfully. Update performed: INSERT
Namespace: TechTalk.Genome
Assembly: TechTalk.Genome (in TechTalk.Genome.dll)
Version: 4.2.4.4
Editions: Professional, Evaluation, Express
UpdateEventArgs Class | TechTalk.Genome Namespace | UpdateEventHandler