Comment convertir le type ‘byte ‘ en ‘System.Data.Linq.Binary’

J’ai une table WorkflowInstances dans ma firebase database qui contient les champs suivants: ID (int), Nom (nvarchar (50), WorkflowID (int), Document (varbinary (MAX) )). Je veux insérer un nouveau WorkflowInstance afin que j’ai écrit ce code

Stream myStream = openFileDialogDoc.OpenFile(); if (myStream != null) { using (myStream) { WorkflowInstance w = new WorkflowInstance(); byte[] bytes = new byte[myStream.Length]; myStream.Read(bytes, 0, (int)myStream.Length); w.ID = repository.WorkflowsRepository.GetMaxIDWokflowInstance() + 1; w.Name = textBoxWorkflowInstanceName.Text; w.CurrentStateID = repository.WorkflowsRepository.GetWorkflowFirstState((int)listBoxMyWorkflows.SelectedValue); w.WorkflowID = (int)listBoxMyWorkflows.SelectedValue; w.CreationDate = System.DateTime.Now.ToSsortingng(); w.Document = bytes; RapidWorkflowDataContext context = new RapidWorkflowDataContext(); context.WorkflowInstances.InsertOnSubmit(w); context.SubmitChanges(); } } 

J’ai une erreur à la ligne 15, l’erreur est la suivante: Impossible de convertir implicitement le type ‘byte []’ en ‘System.Data.Linq.Binary’.

System.Data.Linq.Binary a un constructeur prenant 1 argument de byte[] :

 w.Document = new System.Data.Linq.Binary(bytes);