Exemplo n.º 1
0
        /// <summary>
        /// Enlist an Entity for automatic Auditing.
        /// Use this overload to explicitly declare a primary key selector.
        /// </summary>
        /// <example>db.Audit&lt;Product&gt;(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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Enlist an Entity for automatic Auditing.
        /// Use this overload to resolve primary keys automatically.
        /// </summary>
        /// <example>db.Audit&lt;Product&gt;();</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);
        }