我有以下型號:如何包括只讀在OData的查詢屬性
public class Employee
{
public int EmployeeId { get; set; }
public string Name { get; set; }
[...]
public int OfficeId { get; set; }
public string OfficeInfo
{
get { return Office.Info; }
}
public Office Office { get; set; }
}
public class Office
{
public int OfficeId { get; set; }
public string Info { get; set; }
}
我在客戶端的網格我想與員工的情況下喂,包括OfficeInfo其中行其中一列,所以我消費它通過以下查詢:
「/?的OData /員工$展開;辦公室& $選擇=僱員,名稱,OfficeInfo」
我已經註冊了兩個實體IEdmModel:
private static IEdmModel GetEDMModel()
{
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Employee>("Employees");
builder.EntitySet<Office>("Offices");
[...]
}
和我的獲取動作看起來是這樣的:
[EnableQuery]
public IQueryable<Employees> Get()
{
[...]
}
,但我不斷收到此異常:
「找不到一個叫上鍵入‘OfficeInfo’「屬性Xds.Entities.Employee '「
我在這裏錯過了什麼?
我知道它不會回答你的問題問題,但有沒有什麼阻止你使用'Employee.Office.Info'來代替? – smoksnes