Sheritlw
asked on
Linq to sql - Don't understand why I get error from example
I have only been playing with asp.net and linq for about a year and am trying to create a picture portfolio.
I found an example on the web, but am having a problem understanding the function provided.
In the sample app, they receive no error, but in my environment, I recieve an error
value of type system.data.linq.binary cannot be converted to 1 - dimensional array of byte.
The fields in the db are of type image.
Would someone please explain to me what this is doing and why I am getting the error when it table is set up like it.
Thanks
I found an example on the web, but am having a problem understanding the function provided.
In the sample app, they receive no error, but in my environment, I recieve an error
value of type system.data.linq.binary cannot be converted to 1 - dimensional array of byte.
The fields in the db are of type image.
Would someone please explain to me what this is doing and why I am getting the error when it table is set up like it.
Thanks
Private Shared Function GetPhotoBytes(ByVal source As IQueryable(Of Portfolio), ByVal size As PhotoSize) As Stream
Dim imageBytes As Byte()
Select Case size
Case PhotoSize.Large
imageBytes = source.Select(Function(p) p.BeforePicBytesFull).SingleOrDefault
Case PhotoSize.Original
imageBytes = source.Select(Function(p) p.BytesOriginal).SingleOrDefault
Case PhotoSize.Small
imageBytes = source.Select(Function(p) p.BytesThumb).SingleOrDefault
Case Else
imageBytes = source.Select(Function(p) p.BytesPoster).SingleOrDefault
End Select
If imageBytes IsNot Nothing Then
Return New MemoryStream(imageBytes)
Else
Return New MemoryStream()
End If
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sure thing. Glad to help :)
ASKER
Thank you