convert system.data.linq.binary to byte[]

前端 未结 4 829
执念已碎
执念已碎 2020-12-20 11:57

I am storing bytes in a database table. When I retrieve it with Linq 2 sql I get the return type in system.data.linq.Binary.

I am not able to convert th

4条回答
  •  情深已故
    2020-12-20 12:32

    Have you tried calling ToArray() on i.data?

    var img = from i in db.images
          where i.id == key
          select i.data.ToArray();
    

    System.Data.Linq.Binary has a ToArray method just for that purpose.

提交回复
热议问题