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

拜拜、爱过 提交于 2019-12-10 12:56:33

问题


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));

回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/47168183/entity-framework-ora-00932-inconsistent-datatypes-expected-clob-got-char

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!