Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework ORA-00932: inconsistent datatypes: “'expected CLOB got CHAR”

Oracle.ManagedDataAccess.EntityFramework 6.122.1.0 library is used to access to an Oracle Database from MVC ASP.Net application. It is the latest library version from the NuGet as of November, 14th 2017

protected override Expression<Func<MyEntity, object>> getSelector()
{   
    return m => new
    {
        ID = m.ID,
        NAME = m.Name,
        LONGSTRING = "Blah-blah-blah-blah...some thousands characters..." + 
                      m.ID + "blah-blah...blah" 
    };
}

protected override ProblemMethod()
{
    var result = db.MyEntity.Select(getSelector()).ToList();
}

There is the problem. That happens, because very long string (some thousands characters) is concatinated into LONGSTRING , and execution of Select throw the next exception.

ORA-00932: inconsistent datatypes: "'expected CLOB got CHAR"

My class need to get Expression with the GetSelector() overriding. How to overcome the error or get round it? One way to get round is force EF to execute Select on the client. How to do it?

PS: Same question in Russian.

UPDATE

I should have to present MyEntity

 CREATE TABLE MyEntity (ID NUMBER(10), Name VARCHAR2(100));
like image 241
3per Avatar asked Nov 07 '17 22:11

3per


1 Answers

If you want to execute the select on the client (i.e. loading ALL MyEntity's and filtering them on the client), you can do:

var result = db.MyEntity.ToList().AsQueryable().Select(getSelector()).ToList();

The first ToList() loads all entities from the DB. The AsQueryable() allows you to use the Expression function.

I hope this helps.

Cheers, Nicola

like image 62
N. Carrer Avatar answered Nov 17 '22 17:11

N. Carrer