c# - How to convert type 'byte[]' to 'System.Data.Linq.Binary' -
i have workflowinstances table in db contains fields: id (int), name (nvarchar(50), workflowid (int), document (varbinary(max))). want insert new workflowinstance wrote 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.tostring(); w.document = bytes; rapidworkflowdatacontext context = new rapidworkflowdatacontext(); context.workflowinstances.insertonsubmit(w); context.submitchanges(); } }
i got error in line 15, error is: cannot implicitly convert type 'byte[]' 'system.data.linq.binary'
system.data.linq.binary
has constructor taking 1 argument of byte[]
:
w.document = new system.data.linq.binary(bytes);
Comments
Post a Comment