I tried the following:
GetProvinceCodeByLatLong(a.Latitude, a.Longitude)
And I declared this function as follows:
[DbFunction("Core.Models", "fn_GetProvinceCodeByLatLong")] public static string GetProvinceCodeByLatLong(double latitude, double longitude) { throw new NotSupportedException("Direct calls are not supported."); }
In the edmx file, I have the following:
<Function Name="fn_GetProvinceCodeByLatLong" ReturnType="varchar" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo"> <Parameter Name="latitude" Type="float" Mode="In" /> <Parameter Name="longitude" Type="float" Mode="In" /> </Function>
But the Entity Framework throws an exception that cannot be thrown.
This error I get:
The specified method "System.String GetProvinceCodeByLatLong (Double, Double)" in the type "Infrastructure .CustomRepositories.AssetDataRepository" cannot be translated into a storage expression LINQ to Entities
source share