oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

Wrong statement generated for mapped function when using schema #255

Closed ijanusic88 closed 8 months ago

ijanusic88 commented 1 year ago

We need to map a custom function to table-valued function. In the statement generated from EF, database schema is placed on the wrong place.

We are using Oracle.EntityFrameworkCore 6.21.61 Our configuration and mapping:

`public IQueryable GetName(int id) => FromExpression(() => GetName(id));

modelBuilder .HasDbFunction(typeof(MyDbContext).GetMethod(nameof(MyDbContext.GetName), new[] { typeof(int) })) .HasName("GetName") .HasSchema("MySchema");`

It produces following SQL statement: SELECT "g"."ID", "g"."FIRSTNAME", "g"."LASTNAME" FROM "MYSCHEMA".table("GETNAME"(99)) "g"

But it should be: SELECT "g"."ID", "g"."FIRSTNAME", "g"."LASTNAME" FROM table("MYSCHEMA"."GETNAME"(99)) "g"

Exception: "ORA-00903: Invalid Table Name"

alexkeh commented 1 year ago

@ijanusic88 Sorry, I missed this post. Do you have a simple reproducible test case I can try this out to recreate the bug?

alexkeh commented 8 months ago

Closing until we have a more complete test case to verify the bug and identify the root cause. I will reopen when we get a test case.