We have a legacy oracle table where all documents are stored in binary data format using the LONG RAW data type. As a part of system upgradation, we need to insert binary data into the same LONG RAW column via the EF 6.4. Since the file size is very large, we get the error when inserting records into the LONG RAW column. Unfortunatly, it is not possible to change the LONG RAW datatype to BLOB as the legacy system will break if we change anything in the table.
OracleException:ORA-22835 error
Is there any way to insert LONG RAW bynary data using EF 6.4?
See the Sample C# code below.
public class ATTACHMENT
{
public int ID { get; set; }
[StringLength(32)]
public string DATA_TYPE { get; set; }
public byte[] LONG_RAW_DATA { get; set; }
}
bool AddDecument(byte[] doc)
{
var entity = new ATTACHMENT();
entity.DATA_TYPE = ".pdf";
entity.LONG_RAW_DATA = doc;
this._repository.Add(entity);
this._repository.SaveChanges();
return true;
}
We also tried with a stored procedure using entity, but we get the same type of error.
public void AddDecument()
{
byte[] bytes = System.IO.File.ReadAllBytes("C:\\SearchReport.pdf");
StoredProcedureParameter[] params = new StoredProcedureParameter[2];
params[0] = new StoredProcedureParameter { Name = "DATA_TYPE", Value = '.pdf', InputType = OracleDbType.Varchar2 };
params[1] = new StoredProcedureParameter { Name = "LONG_RAW_DATA", Value = bytes, Direction = System.Data.ParameterDirection.InputOutput,InputType = OracleDbType.LongRaw };
var dbSearch = _repository.ExecuteStoredProcedure("ADD_DOCUMENT", params);
}