当我尝试使用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。
它关心“ASP.NET Web API OData”吗?还有'WCF数据服务'这是不同的,这将是很好的在你的问题中指定。 – 2014-09-05 20:24:21
这表明至少有一种类型具有您应该明确查询的子类型。 – 2014-09-05 20:28:46