We help IT Professionals succeed at work.

Get byte[] from IQueryable<byte[]>

Dinesh Bali
Dinesh Bali asked
on
Hi,

I am working on C#, ASP.net application.


I am getting IQueryable<byte[]> from the query.
I need byte[] bytes to pass into the method Read to get the real document.

Please advise the solution


IQueryable<byte[]> AWBFile = from x in repository.Select() where x.OrderCode == ordercode && x.TrackingNumber == trackingNumber select x.AWBimagefile;

byte[] bytes = AWBFile //  Get bytes[] from here
docFromUrl.Read(bytes);

Open in new window


Thanks
Comment
Watch Question

software developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
.ToArray()?

Author

Commented:
Thanks

You mean I need to proceed as

byte[] bytesArr = AWBFile.ToArray();

foreach(var i in bytesArr)
{
  docFromUrl.Read(i);
}

Open in new window

Lukasz Zielinskisoftware developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
Hi,

I do not know what docFromUrl is and how it's .Read() methods works.
But my guess is that this should be enough:

byte[] bytesArr = AWBFile.ToArray();
docFromUrl.Read(bytes);

Author

Commented:
Many thanks for your help.
Solution worked.
Lukasz Zielinskisoftware developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
glad to be helpful!

ziolko.