/// <summary> /// Enlist an Entity for automatic Auditing. /// Use this overload to explicitly declare a primary key selector. /// </summary> /// <example>db.Audit<Product>(p => p.ProductID);</example> /// <typeparam name="TEntity">Type of Entity you wish to audit</typeparam> /// <param name="pkSelector">A lambda expression that accepts a TEntity and returns an object representing the primary key</param> public static EntityAuditor <TEntity> Audit <TEntity>(this IAuditableContext context, Expression <Func <TEntity, object> > pkSelector) { var def = new EntityAuditor <TEntity>(pkSelector.ToPropertyInfo()); context.EntityAuditors.Add(def); return(def); }
/// <summary> /// Enlist an Entity for automatic Auditing. /// Use this overload to resolve primary keys automatically. /// </summary> /// <example>db.Audit<Product>();</example> /// <typeparam name="TEntity">Type of Entity you wish to audit</typeparam> public static EntityAuditor <TEntity> Audit <TEntity>(this IAuditableContext context) { var def = new EntityAuditor <TEntity>(GetEntityPkProperty <TEntity>(context).ToPropertyInfo()); context.EntityAuditors.Add(def); return(def); }