First, fnTest must first be created as a user-defined function in the database:
CREATE FUNCTION [fnTest] (@fi int, @f2 int, @param3 int, @param4 int) RETURNS int AS ...
Then, in your .edmx file, declare the function as follows:
<Function Name="fnTest" ReturnType="int" Schema="dbo" > <Parameter Name="f1" Mode="In" Type="int" /> <Parameter Name="f2" Mode="In" Type="int" /> <Parameter Name="param3" Mode="In" Type="int" /> <Parameter Name="param4" Mode="In" Type="int" /> </Function>
Now you can bind this function to a method in your model as follows:
[EdmFunction("MyNamespace", "fnTest")] public static int fnTest(int f1, int f2, int param3, int param4) { throw new NotSupportedException("Direct calls are not supported."); }
Now you can use this method in standard LINQ queries.
additional literature
source share