Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryableAttribute doesn't support query on public field #13

Closed
LianwMS opened this issue Jan 12, 2015 · 4 comments
Closed

QueryableAttribute doesn't support query on public field #13

LianwMS opened this issue Jan 12, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@LianwMS
Copy link
Contributor

LianwMS commented Jan 12, 2015

To repro:

public class Movie
{
public string Name = null;
}

public class MoviesController : ApiController
{
[Queryable]
public IEnumerable Get()
{

return new Movie[] {
  new Movie {
    Name = "Test"
  }
}

}
}

Send request: [ http://localhost/api/Movies?filter=Name eq null Response:
HTTP/1.1 ](http://localhost/api/Movies?filter=Name eq null

Response:

HTTP/1.1) 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcaG9uZ3llc1xkb2N1bWVudHNcdmlzdWFsIHN0dWRpb
yAyMDEyXFByb2plY3RzXE12Y0FwcGxpY2F0aW9uMlxNdmNBcHBsaWNhdGlvbjJcYXBpXE1vdmllcw=
=?=
X-Powered-By: ASP.NET
Date: Fri, 21 Sep 2012 18:30:50 GMT
Content-Length: 2070

{"$id":"1","Message":"The query specified in the URI is not
valid.","ExceptionMessage":"Type 'MvcApplication2.Models.Movie' does not have
a property
'Field'.","ExceptionType":"Microsoft.Data.OData.ODataException","StackTrace":"
at Microsoft.Data.OData.Query.MetadataBinder.BindPropertyAccess(PropertyAccess
QueryToken propertyAccessToken)\r\n at
Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Micros
oft.Data.OData.Query.MetadataBinder.BindBinaryOperator(BinaryOperatorQueryToke
n binaryOperatorToken)\r\n at
Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at
Microsoft.Data.OData.Query.MetadataBinder.ProcessFilter(QueryNode query,
QueryToken filter)\r\n at
Microsoft.Data.OData.Query.MetadataBinder.BindTree(SyntacticTree syntax)\r\n
at Microsoft.Data.OData.Query.MetadataBinder.BindQuery(SyntacticTree
syntax)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri,
Uri serviceBaseUri, IEdmModel model, Int32 maxDepth)\r\n at
Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri
serviceBaseUri, IEdmModel model)\r\n at
System.Web.Http.OData.Query.FilterQueryOption.get_QueryNode() in C:\dd\DevDiv
Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Query\Fil
terQueryOption.cs:line 68\r\n at
System.Web.Http.OData.Query.FilterQueryOption.ApplyTo(IQueryable query,
ODataQuerySettings querySettings, IAssembliesResolver assembliesResolver) in C
:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\ODa
ta\Query\FilterQueryOption.cs:line 123\r\n at
System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query,
ODataQuerySettings querySettings) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime
\runtime\src\System.Web.Http.OData\OData\Query\ODataQueryOptions.cs:line
185\r\n at
System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext
actionExecutedContext) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\sr
c\System.Web.Http.OData\QueryableAttribute.cs:line 173"}

Work Item Details

Original CodePlex Issue: Issue 441
Status: Proposed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Sep 21, 2012 at 7:36 PM
Reported by: hongyes
Updated on: Sep 19, 2013 at 11:35 PM
Updated by: danroth27

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2012-09-22 04:05:03 UTC, raghuramn commented:

This is by design. We support only public properties.

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2012-09-25 06:43:16 UTC, HongmeiG commented:

We should support public fields in our conventional model builder by default, and customer can use IgnoreDataMember to opt out.

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2013-04-02 06:35:02 UTC, HongmeiG commented:

OData formatter does not serialize public fields today.

if we decided to support public fields, then we should change the formatter as well as model builder to understand fields.

@LianwMS LianwMS added this to the vNext milestone Jan 12, 2015
@xuzhg xuzhg self-assigned this Feb 17, 2016
@xuzhg xuzhg modified the milestones: v5.9, vNext Feb 17, 2016
@xuzhg
Copy link
Member

xuzhg commented Feb 17, 2016

We support only public properties. Close it.

@xuzhg xuzhg closed this as completed Feb 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants