REPRODUCE:
1. Create a table that has one or more time(7) columns
2. Set Entities.AuditingEnabled = true
3. Generate classes (time(7) will be generated as TimeSpan)
4. Insert an object with the TimeSpan set and SubmitChanges()
5. Call DataContext.LastAudit.ToXml();
EXPECTED: Audit data in xml format
ACTUAL: Exception thrown - "The type System.TimeSpan was not expected. Use the
XmlInclude or SoapInclude attribute to specify types that are not known
statically"
VERSION: PLINQO, CodeSmith.Data 5.0.1.1966
WORK AROUND:
Add a class as follows;
public static object FormatTimeSpan(MemberInfo memberInfo, object value)
{
var t = value as TimeSpan?;
if (t == null || !t.HasValue)
return value;
return System.Xml.XmlConvert.ToString(t.Value);
}
and place the following data annotation above TimeSpan properties in an
Entity's partial, Metadata class;
[AuditPropertyFormat(typeof(CustomAuditFormat),"FormatTimeSpan")]
Original issue reported on code.google.com by stafford...@gmail.com on 30 Jul 2012 at 1:34
Original issue reported on code.google.com by
stafford...@gmail.com
on 30 Jul 2012 at 1:34