问题
Trying to get this to work. The query returns all rows even though I am specifying only one (?$select=title). On the webapiconfig I have:
var queryAttribute = new QueryableAttribute()
{
AllowedQueryOptions = AllowedQueryOptions.All
};
config.EnableQuerySupport(queryAttribute);
The controller looks like this:
public override IQueryable<_person_TITLE> Get()
{
return db.personTitle.AsQueryable();
}
protected override _person_TITLE GetEntityByKey(int key)
{
return db.personTitle.FirstOrDefault(p => p.person_TITLE_ID == key);
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
EDIT: After doing some more digging, I found that $select has never been officially implemented. That is why it is not turned on in the AllowedQueryOptions by default.
So, what does that mean??? having this option is critical. Putting odata web api into production would be silly without this option. Coding in your own handlers would defeat the purpose of employing web api in the first place.
回答1:
We are working on it right now. Support for $select and $expand should show up in the nightly builds very soon.
来源:https://stackoverflow.com/questions/16093783/web-api-odata-select-not-working