1

I am trying to fetching records from oracle database table using web api from country mater table having columns "CountryName", "CountryCode" and "country image" (blob). I am not able to include blob column along with other data:

Current Code:

   // Data Access (Repository) layer for fetching data using Dapper
    public override IQueryable<Country> GetCountryList()
             {
               string query = "select CountryName, CountryCode from Country";
               connection.Open();
               return connection.Query<Country>(query).AsQueryable();
             }    



   // Web API controller
    public IHttpActionResult Get()
            {
               var JsonResponse = ;
               return Ok(GetCountryList().ToList());
            }    

Expected Result:

I want to include CountryImage column which is BLOB type along with existing columns (query below for reference). i.e. "select CountryName, CountryCode, CountryImage from Country";

I will be consuming this data in my Angular application.

Tushar
  • 13
  • 3
  • Take a look at this : [https://stackoverflow.com/questions/39045383/retrieve-image-from-oracle-db](https://stackoverflow.com/questions/39045383/retrieve-image-from-oracle-db) – kgzdev Mar 13 '18 at 13:53

1 Answers1

0

To embed a BLOB into json, the code will have to encode to base64 so it can be included in the json

This has been covered in this SO answer:

Base64 encoding and decoding in oracle

Kris Rice
  • 3,300
  • 15
  • 33
  • Thanks for sharing; also let me know in case you know of any limitation of this approach ? – Tushar Mar 14 '18 at 15:05
  • Sheer size will be the limiting factor. Clearly doing xxGB this way won't be ideal. For that I would make the JSON have a reference URI then that URI is a targeted access to the LOB which could be streamed binary. – Kris Rice Mar 14 '18 at 15:32