Hello, I am using dblinq on mysql. I used the dbmetal to generate the
entities datacontext class in VB. Things all seems fine but except
with columns of DateTime with null value allowed. DbMetal generate
System.Nullable(Of Date) as the column properties of course, like the
following
<Column(Storage:="_birthDate", Name:="Birth Date", DbType:="datetime",
AutoSync:=AutoSync.Never), _
DebuggerNonUserCode()> _
Public Property BirthDate() As System.Nullable(Of Date)
Get
Return Me._birthDate
End Get
Set
If _birthDate <> Value Then
Me.OnBirthDateChanging(Value)
Me.SendPropertyChanging()
Me._birthDate = Value
Me.SendPropertyChanged("BirthDate")
Me.OnBirthDateChanged()
End If
End Set
End Property
Doesn't look like any problem upon first look. However, when I put my
application to test, I found out all my birthdate columns alike
doesn't get updated/inserted into the mysql database. Checked the
bindings, can't seem to find anything wrong. And when I started
debugging my program by stepping into the little piece of code above,
and bang, the "if _birthDate <> Value then" always evaluate to a false
regardless of the Value being "Nothing" or a valid date.
I don't have much experience playing with nullable types in VB, so I
checked around the internet. The problem can be fixed by replacing it
with "if Nullable.Compare(_birthDate, Value) <> 0 then", then things
start to work ok. I am not sure if it affects Nullable of integer,
string, or other types as well, but nullable of date seems just not
working for me using the default code from DbMetal.
I am not really sure if my fix is a fix or I misuse Nullable type,
just want to check with you guys to see if it's really a problem and
hope the Dblinq coders could fix it in the future. Thanks.
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en.