web api odata:$select 不工作 [英] web api odata: $select not working

查看:28
本文介绍了web api odata:$select 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图让它发挥作用.即使我只指定了一个 (?$select=title),查询也会返回所有行.在 webapiconfig 我有:

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);

控制器看起来像这样:

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);
        }

再挖了一些,发现 $select 一直没有正式实现.这就是默认情况下它没有在 AllowedQueryOptions 中打开的原因.

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.

所以,这是什么意思???拥有此选项至关重要.如果没有这个选项,将 odata web api 投入生产将是愚蠢的.在您自己的处理程序中编码首先会违背使用 web api 的目的.

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.

推荐答案

我们正在着手解决.对 $select 和 $expand 的支持应该很快就会出现在每晚构建中.

We are working on it right now. Support for $select and $expand should show up in the nightly builds very soon.

这篇关于web api odata:$select 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆