Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

difficult behavior with sqlqueryraw odp.net ef core 9.23.60 query translation

Hi, I'm aware of special, oracle ef core query translation, with oracle odp.net e.g. this post for instance :

https://forums.oracle.com/ords/apexds/post/ora-00904-t-value-invalid-identifier-using-sqlquery-and-si-2228

But when we want to pass a simple raw SQL query with ef core like this one, using SqlQueryRaw ef core function :

int? lastVal = _applicationDbContext.Database.SqlQueryRaw<int>(@"SELECT pack_util_metier.get_current_site_no AS ""Value"" FROM DUAL").FirstOrDefault();

Oracle is transforming this query with something like

SELECT "t"."Value"
 FROM (SELECT pack_util_metier.get_current_site_no AS "Value" FROM DUAL) "t"

So we are forced in our C# code to explicitely add AS “Value” in each query we want to pass.

Furthermore a simple query to get a db sequence like “SELECT myseq.NEXTVAL FROM DUAL” needs to enclosed in a function otherwise it doesn't work because of:

SELECT "t"."Value"
 FROM (SELECT myseq.NEXTVAL  AS "Value" FROM DUAL) "t" results in a ora-02287 sequence number not allowed here.

Is there an option with oracle ef core driver to bypass this behavior ?

Thank's

Olivier

This post has been answered by Alex Keh-Oracle on Mar 3 2025
Jump to Answer

Comments

Post Details

Added on Mar 1 2025
1 comment
60 views