當我嘗試使用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