'<FieldName>' is not a member of type '<Type>' in the currently loaded schemas
I have the following function defined in the CSDL of my EDMX.
<Function Name="GetSprintDuration" ReturnType="Edm.Decimal">
<Parameter Name="sprintId" Type="Edm.Int32" />
<DefiningExpression>
SUM( SELECT VALUE h.Duration
FROM ApplicationEntities.Hours as h
WHERE h.Story.Project.SprintId = sprintId)
</DefiningExpression>
</Function>
My code for accessing the function looks like:
[EdmFunction("ApplicationModel", "GetSprintDuration")]
public decimal? GetSprintDuration(int sprintId)
{
return this.QueryProvider.Execute<decimal?>(Expression.Call(
Expression.Constan开发者_如何转开发t(this),
(MethodInfo)MethodInfo.GetCurrentMethod(),
Expression.Constant(sprintId, typeof(int))));
}
When I call this method I receive the following error:
'SprintId' is not a member of type 'ApplicationModel.Project' in the currently loaded schemas.
The error is being generated when the QueryProvider.Execute is called:
Line 17: public decimal? GetSprintDuration(int sprintId)
Line 18: {
Line 19: return this.QueryProvider.Execute<decimal?>(Expression.Call(
Line 20: Expression.Constant(this),
Line 21: (MethodInfo)MethodInfo.GetCurrentMethod(),
If I change the function to something like:
<Function Name="GetSprintDuration" ReturnType="Edm.Decimal">
<Parameter Name="sprintId" Type="Edm.Int32" />
<DefiningExpression>
SUM( SELECT VALUE h.Duration
FROM ApplicationEntities.Hours as h
WHERE h.HourId != 0)
</DefiningExpression>
</Function>
My application functions as normal ... for some reason I don't have access to the full entity model. Is there a way to make it so that I can access the full entity model OR is this not possible?
Thanks in advance!
With the help of @Henk Holterman I was able to figure my problem out ... I didn't realize that ESQL supported JOINS, so here is what the working code looks like:
<Function Name="GetSprintDuration" ReturnType="Edm.Decimal">
<Parameter Name="sprintId" Type="Edm.Int32" />
<DefiningExpression>
SUM( SELECT VALUE h.Duration
FROM ApplicationEntities.Hours as h
JOIN ApplicationEntities.Stories as s on h.StoryId == s.StoryId
WHERE s.SprintId == sprintId )
</DefiningExpression>
</Function>
精彩评论