Friday, November 5, 2010

Subsonic ActiveRecord CreatedBy, ModifiedBy, etc

On ActiveRecord.tt


public void Update(IDataProvider provider){
...
}


removed the following block codes:


if(tbl.Columns.Any(x=>x.Name=="ModifiedBy")){
if(String.IsNullOrEmpty(this.ModifiedBy))
this.ModifiedBy=Environment.UserName;
}



if(tbl.Columns.Any(x=>x.Name=="ModifiedOn")){
this.ModifiedOn=DateTime.Now;
}


after that the method should look like the one below:


public void Update(IDataProvider provider) {
if(this._dirtyColumns.Count>0)
_repo.Update(this,provider);
OnSaved();
}


Similarly remove the rest of the Update() methods. Do the same with the Add() methods.

No comments: