I have a problem with Entity Developer and model defined function. Ealier I was mapping functions as a stored procedures because Entity Developer has no support for database functions as it goes. I was using solution mentioned in this topic from devart forum. But it has no use for me now, because I can't use it in Linq
query as a part of bigger select statement on entity.
I am trying to add function like this and make it the way it is mentioned here. But i am getting this exception
Additional information: LINQ to Entities does not recognize the method 'System.Nullable
1[System.Int32] EwBlobIleWyst(System.String, System.Nullable
1[System.Int32], System.String, System.Nullable`1[System.Int32])' method, and this method cannot be translated into a store expression.
In ssdl file function is generated like this:
<Function Name="EW_BLOB_ILE_WYST" IsComposable="true" ReturnType="decimal" BuiltIn="false" Aggregate="false" NiladicFunction="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="EWID4" StoreFunctionName="EW_BLOB_ILE_WYST">
<Parameter Name="OWNER" Type="VARCHAR2" Mode="In" />
<Parameter Name="OWNER_ID" Type="decimal" Mode="In" />
<Parameter Name="RODZ_DOK_IDS" Type="VARCHAR2" Mode="In" />
<Parameter Name="LICZ_PUSTE" Type="decimal" Mode="In" />
In csdl file it is like this :
<Function Name="EwBlobIleWyst" ReturnType="Collection(Int32)" ed:Guid="f544518f-1cdd-484c-92b4-73b61491dc54">
<Parameter Name="OWNER" Type="String" />
<Parameter Name="OWNER_ID" Type="Int32" />
<Parameter Name="RODZ_DOK_DS" Type="String" />
<Parameter Name="LICZ_PUSTE" Type="Int32" />
<DefiningExpression>SELECT EWID4.EW_BLOB_ILE_WYST(:OWNER, :OWNER_ID, :RODZ_DOK_IDS, :LICZ_PUSTE) FROM KDOK_WSK</DefiningExpression>
And my implementation looks like this :
[EdmFunction(@"Ewid4", @"EwBlobIleWyst")]
public virtual global::System.Nullable<int> EwBlobIleWyst(string OWNER, global::System.Nullable<int> OWNER_ID, string RODZ_DOK_IDS, global::System.Nullable<int> LICZ_PUSTE)
{
throw new NotSupportedException();
}
This code is inside partial context class. And I am using it in this way :
DokPow = ((Ewid4)context).EwBlobIleWyst("smth", 1, null, 0)
This snippet is inside select of queryable using Linq