Dixin / EntityFramework.Functions

EntityFramework.Functions library implements Entity Framework code first support for stored procedures (with single result type, multiple result types, output parameter), table-valued functions (returning entity type, complex type), scalar-valued functions (composable, non-composable), aggregate functions, built-in functions, niladic functions, and model defined functions.
https://weblogs.asp.net/Dixin/EntityFramework.Functions
MIT License
79 stars 27 forks source link

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

Closed jdwill916 closed 3 years ago

jdwill916 commented 6 years ago

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?

ChristosMylonas commented 6 years ago

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

jdwill916 commented 6 years ago

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?

ChristosMylonas commented 6 years ago

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

jdwill916 commented 6 years ago

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.

uPloraX commented 6 years ago

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