Business object mapper and images


Author
Message
GRocchi
GRocchi
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 56
I have an image in my database, I setup the business object mapper with CustomObject Type = System.Drawing.Bitmap and the flag serialize to true, null value option= don't allow null. I rebuild and get the following working code:
Set(ByVal value As System.Drawing.Bitmap)
Dim loStream As New MemoryStream()
Me.BinaryFormatter.Serialize(loStream, value)
Me.CurrentRow.Item("Immagine") = loStream.ToArray()
End Set

When I change the option null value option= return alternate on null/Set null on alternate(reference type) the code generated is the following:

Set(ByVal value As System.Drawing.Bitmap)

Dim loStream As New MemoryStream()

if value IsNot Nothing Then

Me.CurrentRow.Item("Immagine") = loStream.ToArray()

Else

Me.CurrentRow.Item("Immagine") = DBNull.Value

End If

End Set

It seems that the row

Me.BinaryFormatter.Serialize(loStream, value)   

gets missing. In fact I added it manually and all works fine.

Is there a better way to achieve this? Is this by design?

Thanks in advance


Gianpaolo Rocchi

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search