Active Record Pattern

One of the available patterns that can be used with an O/RM and a domain model is the Active Record (AR) pattern. The principal requisites of this pattern are: the domain entity represents a table of the database with a one to one relationship; the domain entity exposes the properties of the corresponding database table, and the Create, Read, Update, and Delete (CRUD) commands and foreign keys relationship are exposed with object references. Listing 6-1 show a pseudo-code version of the Active Record implementation.

Listing 6-1. Sample Active Record Pattern Code

Customer customer = new Customer(); customer.FirstName = "Raffaele"; customer.LastName = "Garofalo"; customer.Save();

The code creates a new object AR of type ...

Get Applied WPF 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.