【发布时间】:2015-01-09 15:02:07
【问题描述】:
例如,我有两个类
public class Location
{
public int Id { get; set; }
public string Name { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string Town { get; set; }
public string County { get; set; }
public string CountryCode { get; set; }
}
public class Customer : Location
{
public string BankAccountNumber { get; set; }
public string BankSortCode { get; set; }
}
在我的查询中,我返回了所有位置和客户。
http://localhost:80/odata/Location?select=Id,Name,Town
但是,如果我尝试在客户中选择任何内容(编辑:所以我想要所有位置,但如果该位置也是客户,则需要银行帐号),我会收到错误消息。
http://localhost:80/odata/Location?select=Id,Name,Town,BankAccountNumber
"The query specified in the URI is not valid. Could not find a property named 'BankAccountNumber' on type 'MyNamespace.Location'."
有什么方法可以选择继承类型中的字段,而不选择全部?谢谢。
【问题讨论】:
-
您能否向我们展示一下您是如何在 webapi 配置中配置 OData 端点以及您的 Dbcontext 的样子?也许我们可以在那里找到一些东西
标签: c# asp.net-web-api odata