web api odata: $select not working

雨燕双飞 提交于 2019-12-22 08:57:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!