试图标记为ODATA时可查询属性不是MVC 4个Web API编译 [英] Queryable attribute is not compiling in mvc 4 web api when trying to mark for odata

查看:102
本文介绍了试图标记为ODATA时可查询属性不是MVC 4个Web API编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用附带的Visual Studio 2012 MVC 4个Web API。

I'm using MVC 4 web api that comes with visual studio 2012.

因为我已经明白ODATA不会自动分析,但我们需要的属性现在加上[可查询]的动作。

As I've understand odata is not parsed automatically, but we need to add [Queryable] attribute to the action now.

所以我添加它:

public class TestController : ApiController
{
    [Queryable]
    public IQueryable<MyClass> GetMyClasses()
    {
       return ...;
    }
}

但我发现了一个编译错误:

but I'm getting a compilation error:

The type or namespace name 'Queryable' could not be found (are you missing a using directive or an assembly reference?) 

时的ODATA仍然支持?为什么可查询不被识别为属性,如这里列出。

Is the odata still supported? and why Queryable is not recognized as an attribute as listed here.

感谢您

推荐答案

作为解释<一个href=\"http://blogs.msdn.com/b/alexj/archive/2012/08/15/odata-support-in-asp-net-web-api.aspx\">here, OData的支持已被移动到一个单独的的NuGet包

As explained here, OData support has been moved to a separate NuGet package.

这篇关于试图标记为ODATA时可查询属性不是MVC 4个Web API编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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