Entity Framework ORA-00932: inconsistent data types: "expected CLOB received CHAR"

The Oracle.ManagedDataAccess.EntityFramework 6.122.1.0 library is used to access the Oracle database from ASP.Net MVC application. This is the latest version of the library from NuGet as of November 14, 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 a problem. This is because a very long string (several thousand characters) is combined into LONGSTRING , and executing Select raises the following exception.

ORA-00932: inconsistent data types: "expected CLOB received CHAR"

My class should get Expression with an override of GetSelector() . How to overcome a mistake or get around it? One way around this is to force EF to perform Select on the client. How to do it?

PS: The same question in Russian.

UPDATE

I need to introduce MyEntity

  CREATE TABLE MyEntity (ID NUMBER(10), Name VARCHAR2(100)); 
+7
c # oracle entity-framework clob oracle-manageddataaccess
source share
2 answers

If you want to make a selection on the client (i.e. load ALL MyEntity 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 database. AsQueryable () allows you to use the Expression function.

Hope this helps.

Cheers nicola

+4
source share

Instead of returning the object to getselector (), return an interface (after casting) or a specific type. This should help the organization structure in determining the appropriate data type.

0
source share

All Articles