public virtual ObjectResult<Nullable<byte>> GetPersonalPicture3(Nullable<System.Guid> contactId)
{
var contactIdParameter = contactId.HasValue ?
new ObjectParameter("ContactId", contactId) :
new ObjectParameter("ContactId", typeof(System.Guid));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Nullable<byte>>("GetPersonalPicture3", contactIdParameter);
}
in the bottom Code, I Faced this error "The specified cast from a materialized 'System.Byte[]' type to a nullable 'System.Byte' type is not valid."
byte x = DBPSO.GetPersonalPicture3(ProfileID).FirstOrDefault() ?? 0000;
in addition, I've tested this Code too
var x = DBPSO.GetPersonalPicture3(ProfileID).Select(B => B.Value).ToArray();
string binaryPic = System.Text.Encoding.Unicode.GetString(x);
The picture on the db is probably a varbinary so an array of byte and not a single byte. Try this:
public virtual ObjectResult<byte[]> GetPersonalPicture3(Nullable<System.Guid> contactId)
{
var contactIdParameter = contactId.HasValue ?
new ObjectParameter("ContactId", contactId) :
new ObjectParameter("ContactId", typeof(System.Guid));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<byte[]>("GetPersonalPicture3", contactIdParameter);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments