当我尝试使用带有 $expand 的 OData 查询时,会产生以下错误:
DbIsOfExpression requires an expression argument with a polymorphic result type that is compatible with the type argument.
我不确定我做错了什么,而且谷歌并没有真正揭示这个错误背后的太多信息。该项目的所有引用都很好,并且所有其他 OData 查询都按预期工作。
以下是相关的数据模型:
public class ViewLink
{
public string OverrideLinkName { get; set; }
public string OverrideDescription { get; set; }
public bool IsActive { get; set; }
public int ViewLinkID { get; set; }
public Nullable<int> ViewID { get; set; }
public Nullable<int> LinkID { get; set; }
public Nullable<int> CreatedByID { get; set; }
public virtual View View { get; set; }
public virtual Link Link { get; set; }
}
public partial class View
{
public Nullable<int> SchoolID { get; set; }
public string ViewName { get; set; }
public int ViewID { get; set; }
public Nullable<int> ViewTypeID { get; set; }
public Nullable<int> TeacherID { get; set; }
public virtual ViewType ViewType { get; set; }
}
public partial class ViewType
{
public string TypeName { get; set; }
public Nullable<int> Priority { get; set; }
public int ViewTypeID { get; set; }
}
当我尝试使用以下 OData 查询时会产生错误:
http://apilinkhere.com/api/viewlink?$top=1&$expand=View/ViewType
我需要在某处更改设置吗?我只是想在我做错的事情背后被引导到正确的方向,并了解这里发生的事情。我不想在以后的项目中继续出现这个错误。
如果还有其他需要,我会尽力制作。
编辑:
我正在使用 Web API OData。