EntityFramework.Functions icon indicating copy to clipboard operation
EntityFramework.Functions copied to clipboard

Does not work with Oracle DB functions that are in a package.

Open jdwill916 opened this issue 8 years ago • 5 comments

This does not work for anything that is in a package, due to packages requiring a separate period of separation. When a package is used, the SQL generated needs to be in the pattern of "[schema]"."[package]"."[function]"(), but this software only supports the pattern of "[schema]"."[function]"().

I have attempted to use the add the package to the schema parameter as Schema = "mySchema.myPackage" but this renders the SQL like this: "mySchema.myPackage"."myFunction"() leaving the "." inside of the quotes, and causing the database to look for a schema called mySchema.myPackage which does not exist.

Would it be possible to add in an optional "Package" parameter to the attribute call that, if populated, would add in the supplied package to the query?

jdwill916 avatar May 18 '18 16:05 jdwill916

You can call Oracle package procedures/functions using function attribute. For example to call GETVERSIONBYPRODUCTNAMEFUNC function on EF_TESTPACKAGE of MYSCHEMA schema use:

[Function(FunctionType.StoredProcedure, "GetVersionByProductNamePackageFunction", 
Schema = "MYSCHEMA", StoreFunctionName = "EF_TESTPACKAGE.GETVERSIONBYPRODUCTNAMEFUNC")]
public ObjectResult<Entity.Version> GetVersionByProductNamePackageFunction(string productName)
{
            ObjectParameter productNameParameter = !String.IsNullOrEmpty(productName)
                ? new ObjectParameter("piProductName", productName)
                : new ObjectParameter("piProductName", typeof(string));

            var a = this.ObjectContext();
            return this.ObjectContext().ExecuteFunction<Entity.Version>(
                "GetVersionByProductNamePackageFunction", productNameParameter);
 }

more on https://github.com/Dixin/EntityFramework.Functions/pull/29

ChristosMylonas avatar May 18 '18 18:05 ChristosMylonas

Thank you for adding this! I have downloaded the latest version of the project from NuGet (1.4.1) and the StoreFunctionName parameter is not found. Will this be in the next NuGet version, and is there an estimated time-frame when it will be deployed?

jdwill916 avatar May 18 '18 19:05 jdwill916

I think that it has already been deployed. :smile:

ChristosMylonas avatar May 18 '18 20:05 ChristosMylonas

Sadly, it has not, as far as I can tell, been added to the most recent NuGet package (1.4.1). Hopefully it will be added soon.

jdwill916 avatar May 21 '18 16:05 jdwill916

Sadly it's not in the compiled version of v1.4.1. Could you please release a newer version @Dixin?

uPloraX avatar Jun 25 '18 13:06 uPloraX