Search code examples
c#oracle11gef-code-firstdotconnectentity-framework-6.1

dotConnect: CROSS APPLY is not supported by Oracle Database 11g


I'm trying to execute this code block using devart dotConnect 8.4 + EF6.1:

var menus = (from m in dbSet
             from p in m.RegraAcesso.Perfis
             from u in p.Usuarios
             where u.Id == userId && m.Pai.RegraAcesso.Token.Equals(module)
             select m)
            .Include(p => p.Pai)
            .ToList();

But it throws this error:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: CROSS APPLY is not supported by Oracle Database 11g and lower. Oracle 12c or higher is required to run this LINQ statement correctly. If you need to run this statement with Oracle Database 11g or lower, rewrite it so that it can be converted to SQL, supported by the version of Oracle you use.

I'm using: dotConnect for Oracle 8.4.171.0 + EF6.1 (Code-First) + Oracle 11g

It was working with dotConnect for Oracle 7.5.164.0 + EF4 (Code-First) + Oracle 11g


Solution

  • The OUTER APPLY/CROSS APPLY constructions are supported by Oracle server starting from the 12c version. Our implementation in dotConnect for Oracle avoids generation of OUTER APPLY/CROSS APPLY if it is possible, but some LINQ queries cannot be translated without employing OUTER APPLY/CROSS APPLY. In this case you should rewrite your LINQ statement.

    Also, with the development of the Entity Framework engine, the OUTER APPLY/CROSS APPLY constructions may start to be generated in cases, in which earlier were not generated. Thus, we also recommend you to create a small test project and contact the CodePlex support: https://entityframework.codeplex.com/