I am not completely sure whether I need to post this here, or in a bug database which I can not find.I notice that there is a difference in converting a smartdate.
1. TypeDescriptor.GetConverter(typeof(Csla.SmartDate)).ConvertTo(new SmartDate(), typeof(DateTime?))
2. (DateTime?) new SmartDate()
1. returns DateTime.MinValue
2. returns null.
My proposed solution is to change the SmartDateConverter class line 97 to
return (DateTime?) sd;
Please correct me, if there is some flaw in my reasoning.
Thanks, added to the bug list
(The bug list used to have a public interface - but in less than 10 days after making it public, spammers automated an attack and flooded the database with spam. There should really be a way to deal with spammers, something involving substantial physical discomfort and exile from any contact with their fellow humans.)
I have looked into ths issue and it is not a problem/bug with the SmartDateConverter
The code for:
DateTime? dt1 = (DateTime?) new SmartDate();
doesn't hit the SmartDateConverter class but executes the static implicit operator in SmartDate:
/// Convert a SmartDate to a nullable DateTime.
/// <param name="obj1">SmartDate value.</param>
public static implicit operator System.DateTime?(SmartDate obj1)
/// Gets the value as a DateTime?.
public DateTime? ToNullableDate()
return new DateTime?();
return new DateTime?(this.Date);
So the rule SmartDate implements is that an Empty SmartDate converts to a DataTime that is null.
I have discussed this with Rocky and concluded that we do not want to change this code for now.
Copyright (c) Marimer LLC