When using LoadProperty<SmartDate, DateTime?>(myDateProperty, data.myDate) the milliseconds are ignored (set to zero).
I've traced this problem to the CoerceValue() method where the line 169, "tmp.Text = value.ToString();" ignores milisseconds.
Is this a known issue?
I think it depends on your default format string.
As I recall the default is short date.
If you want something different you can set it for each SmartDate or you can set it once for all SmartDates when the app starts up.
Joe
I'm sorry, I don't see where to set a format string that would help.
When I call LoadProperty<SmartDate, DateTime?>(myDateProperty, data.myDate), Csla.CoerceValue() is eventually called and line 169, "tmp.Text = value.ToString();", uses the ToString() of the original DateTime? value (which is "10/10/2008 2:30:14 PM" without milliseconds) to create the tmp SmartDate that is then returned as the property's value.
Is there something that needs to be done to the original value (the DateTime?) so ToString() includes milliseconds?
The offending ToString() is actually called on the loaded value (the DateTime) not the target, SmartDate value.
A solution, that appears to have low impact on the existing code, is to change line 169 of Csla.CoerceValue() to the following:
if (value.GetType().Equals(typeof(DateTime)))
tmp.Date = (DateTime)value;
else
tmp.Text = value.ToString();
This allows direct DateTime and DateTime? conversions to SmartDate, maintaining precision while null values, which are set to string.Empty in an earlier statement, are handled in the "else" (the original line if code).
Thanks for tracking down the details of this issue - I'll add it to the work list.
Copyright (c) Marimer LLC