I need to have a property that is a nullable date as the datestamp is used for when a process is completed.
If there is no date this is a way to determain if the process has occured.
I have created a Nuallable DateTime property (DateTime?) however when i try to assign a value from my database entity(when debugged has a date value) i am not thrown an exception however my property still reads a null value after assignment.
How can i get a DateTime? type to accept a DateTime value? i thought this would do the trick _object.DateStamp (type = DateTime?) = _entity.DateStamp (Type = DateTime?, Value = DateTime) or for more understandable syntax
Ctype(object.DateStamp, DateTime?) = Ctype(entity.DateStamp, DateTime?)
Strange thing is i can assign the properties value like this. Ctype(object.DateStamp, DateTime?) = Now
Oh btw im uisng LinQ Entities.
Any Help?
I had this same problem. I would assign a date from a user entered value and it would never assign to the Nullable Date property on my custom object. My solution was to assign the user entered value into a local Nullable date variable, and then assign that value to the property. Trying to cast the user entered value into a nullable type on a single line didn't work for me either. The solution that worked for me is below:
Dim MyDate As Date? = Date.Parse(Me.txtDate.Text.Trim())
MyObject.Date1 = AppearanceDateAlternate