I've just been researching the ActiveRecord pattern, and based on this (http://en.wikipedia.org/wiki/Active_record_pattern), it seems Linq 2 Sql more or less implements this, am I wrong? or what would need to be changed for it to conform to the ActiveRecord pattern?
In some ways it can feel like an active record pattern, but it really isn't. Basic example:
//load the entity
var c = myDataContext.Customers.FirstOrDefault(c => c.Id == 1876);
c.Name = "George Armstrong Custer";
// saves the entity
myDataContext.SubmitChanges();
Active record
//load the entity
var c = Customer.GetCustomer(9);
c.Name = "Varus";
//save the entity
c.Save();
Active record really just involves one class which covers the model and supplies the data interface Linq to Sql follows a different path where there are a few model classes and a separate data interface, otherwise known as a repository.
PS: For a good example of an ORM that uses the active record pattern, check out Subsonic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With