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

Question

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

Answers 2
Added at 2017-11-07 23:11
Tags
Question

Oracle.ManagedDataAccess.EntityFramework 6.122.1.0 library is used to access to an Oracle Database from MVC ASP.Net application.

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.

Answers to

Entity Framework ORA-00932: inconsistent datatypes: “&#39;expected CLOB got CHAR”

nr: #1 dodano: 2017-11-10 16:11

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

nr: #2 dodano: 2017-11-11 19:11

Instead of returning an object in the getselector() return an interface (after casting) or a concrete type. This should help entity framework in identifying the appropriate datatype.

Source Show
◀ Wstecz