1
Vote

Non ColumnAttribute properties is evaluated

description

line 109 in AuditProcessor.cs:
AuditedEntityField values = resolver.GetAuditValue(pi, null, pi.GetValue(entity, null));

i would like not to call pi.GetValue(entity,null) if it hasn't the ColumnAttribute attribute. right now the check is done after GetValue is called.

I've some custom properties added to my L2S objects which not necessarily evalutes properly if not all associations are binded, like just before the object is inserted. So right now a lot of exceptions is thrown for me when trying to insert objects with audits turned on.

comments

glennen wrote Mar 9, 2009 at 11:58 AM

I replaced line 109 with:
if (pi.GetCustomAttributes(typeof(System.Data.Linq.Mapping.ColumnAttribute), false) == null ||
                    pi.GetCustomAttributes(typeof(System.Data.Linq.Mapping.ColumnAttribute), false).Length == 0)
                    continue;
and it's all good for now

glennen wrote Mar 9, 2009 at 12:00 PM

(where is the Edit function in this Issue tracker? i discovered a lot of typos etc.)

i didn't replace 109, but added the lines before line 109..

glennen wrote Mar 9, 2009 at 1:32 PM

of course that was only a hack. you properly want to extend "IAuditPropertyResolver" with "public bool IsMemberValid(MemberInfo member)" and call that method before "AuditedEntityField values = resolver.GetAuditValue(pi, null, pi.GetValue(entity, null));" and return (continue) if not returns true.

mhidinger wrote Dec 16, 2009 at 3:25 PM

Thanks for reporting this glennen, I will review these changes and likely implement some version of support for this scenario in the next release in a week or so.

-Matt