Business object mapper and images


Author
Message
GRocchi
GRocchi
StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 reputation)StrataFrame Beginner (48 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

Reply
Ross L Rooker, Sr.(1)
Ross L Rooker, Sr.(1)
StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)StrataFrame User (236 reputation)
Group: StrataFrame Users
Posts: 50, Visits: 163
Thanks. I have never used the Custom Code option in the BO Mapper. I assume this is where I use the code you mentioned above. This seems to have allowed me to get the BO to compile. When I reference this picture column in a form bound to a picturebox, when the form displays I get this error:

An exception of type 'MicroFour.StrataFrame.Business.BusinessLayerException' occurred in MicroFour StrataFrame Business.dll but was not handled in user code

Additional information: An error occurred while refreshing the data from field 'tbvo_Groupi.GI_PICTURE' to property 'Image' on control 'pictureBox1.'  Are you missing FieldPropertyDescriptor for a custom property?

Not sure what this may be looking for?



Edited 11 Years Ago by Ross L Rooker, Sr.(1)
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