views:

25

answers:

1

I've just started playing with Matt Hidinger's great looking Doddle Audit, which provides DataContext located automatic auditing of any changes to LINQ to SQL entities. It works great for single entities, but also has a feature for associations, e.g. where Order and Order Items are related, changes to an Order Item reflect under changes to the Order.

He gives several examples on how to audit related tables, but none work for me. I have asked in the forum there, but am hoping someone here may have used the project and have some advice for me. If I try and audit a 'parent-child' relationship, e.g.

Orders.Audit().AuditAssociation(o => o.OrderItems);

On any tables, I always get the error:

Expression of type 'System.Int32' cannot be used for return type 'System.Nullable`1[System.Int32]'

I am new to LINQ to SQL, and suspect something may be wrong there. I simply created and related the tables in SSMS, and dragged them onto the DBML designer.

+1  A: 

This is a problem with the pre-compiled 'official' release, and can be fixe by downloading and building the source yourself. Some minor code changes (mostly field renames) will be required to be compatible with the latest source version.

Leon Coetsee
Note: in the source file 'AuditableDataContext.cs' change line 85 from 'new MemberAudit(mmi.Member, mmi.CurrentValue, mmi.OriginalValue));' to 'new MemberAudit(mmi.Member, mmi.OriginalValue, mmi.CurrentValue));'
Leon Coetsee
The changes to the AuditableDataContext class part that writes to audit tables were a little trickier than I expected, but otherwise everything worked perfectly, thanks. I'm just surprised Matt hasn't fixed the transposition of OriginalValue and CurrentValue even in the latest (19 July) commit.
ProfK