Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Feature: Error when using ODataQueryOptions with primitive return type. [546]

$
0
0
Scenario:
I have a Persons controller, which is a regular Web API controller and not based on OData.
I would like users to be able to supply queryable options on Person and only return small amounts of data rather than the full Person objects.
Example: returning list of names of all Persons whose age > 30 years.

Actual: Error thrown during parameter binding
Expected: Since user wants to take care of applying options himself, he should be able to do whatever he wants within the action and return data of any kind(primitive or non-primitive)

Model
-----
public class Person
{
public string Name { get; set; }

public DateTime DateOfBirth { get; set; }

public int Id { get; set; }
}

Web API Action
--------------
public IEnumerable<string> Get(ODataQueryOptions options)


Exception
---------
{"Message":"An error has occurred.","ExceptionMessage":"No EntitySet exists in the EdmModel with EntityClrType 'System.String'.","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Web.Http.OData.ODataQueryContext..ctor(IEdmModel model, Type entityClrType) in d:\\Runtime\\src\\System.Web.Http.OData\\OData\\ODataQueryContext.cs:line 68\r\n at System.Web.Http.OData.ODataQueryParameterBindingAttribute.ODataQueryParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken) in d:\\Runtime\\src\\System.Web.Http.OData\\OData\\ODataQueryParameterBindingAttribute.cs:line 95\r\n at System.Web.Http.Controllers.HttpActionBinding.<>c__DisplayClass1.<ExecuteBindingAsync>b__0(HttpParameterBinding parameterBinder)\r\n at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()\r\n at System.Threading.Tasks.TaskHelpers.IterateImpl(IEnumerator`1 enumerator, CancellationToken cancellationToken)"}
Comments: Verified. Users can return Persons and can use $select now.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>