Data Access has been discontinued. Please refer to this page for more information.

How to: Materialize Byte Array

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This topic demonstrates how to materialize byte array.

To run the samples in this topic, you need to use\import the System.Data, System.Data.Common and Telerik.OpenAccess.Data.Common namespaces.

Suppose, you have a table with a column of type image. Basically, you need to use the generic ExecuteQuery<T> method of the OpenAccessContext.

private static void MaterializeByteArray()
{
   using ( EntitiesModel dbContext = new EntitiesModel() )
   {
       const string SqlQuery = "SELECT Picture FROM Categories";

       IList<byte[]> pictures = dbContext.ExecuteQuery<byte[]>( SqlQuery );

       foreach ( byte[] bytes in pictures )
       {
           int length = bytes != null
               ? bytes.Length
               : 0;
           Console.WriteLine( "Byte array length: {0}", length );
       }
   }
}
Private Sub MaterializeByteArray()
 Using dbContext As New EntitiesModel()
  Dim sqlQuery As String = "SELECT Picture FROM Categories"

  Dim pictures As IList(Of Byte()) = dbContext.ExecuteQuery(Of Byte())(sqlQuery)

  For Each bytes As Byte() In pictures
   Dim length As Integer = If(bytes IsNot Nothing, bytes.Length, 0)
   Console.WriteLine("Byte array length: {0}", length)
  Next bytes
 End Using
End Sub