Post-commit hooks
Introduction
using Starcounter;
[Database]
public class Order
{
// Properties
}
public class Program
{
static void Main()
{
Hook<Order>.AfterCommitInsert += (sender, id) =>
{
// Executes after you commit a new Order
var order = Db.FromId<Order>(id);
SendConfirmationEmail(order);
};
// Create a new order and trigger the hook
Db.Transact(() => new Order());
}
private static void SendConfirmationEmail(Order order)
{
// Implementation for sending a confirmation email
}
}API
Invocation
Triggering hooks
Infinite loops
Invocation timing
Durability
Registering hooks
Advanced: post-commit hooks with a custom scheduler
Last updated