views:

205

answers:

2

I am using SubSonic 3.0.0.3 in SimpleRepository mode. I was wondering how to get Subsonic 3 to automatically create and populate the createdon, createdby etc audit fields that were standard in version 2.x .

Is this something I have to configure with the T4 templates?

+1  A: 

You'll need to use the ActiveRecord templates to get the audit fields to be automatically populated. SimpleRepository doesn't provide any other functionality than simple data access so you'd need to populate these fields yourself.

Adam
A: 

I really wanted to stick totally with SimpleRepository, its a very good fit for our needs at this point.

So my immediate solution is to have all my domain model classes inherit from a DataEntity abstract class:

public abstract class DataEntity {

        public string Name { get; set; }
        public int ID { get; set; }

        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string ModifiedBy { get; set; }
        public DateTime ModifiedOn { get; set; }
        public bool IsDeleted { get; set; }

      }

What does everyone think? These properties are not just for bookkeeping, they are relevant to the app domain model so I thought it would be better to treat them as first class members of the DAL.

Alex