1

Closed

"Argument types do not match" OData error

description

The following two pieces of code crashes with the same error message "Argument types do not match"

NOTE: The query used is "http://localhost:52473/api/myentity/bymunicipality/4fba6fd37fbbc823acdf1d36?$filter=startswith(Name,'Test') eq true"

[Queryable]
public async Task<HttpResponseMessage> GetByMunicipality(string municipalityId)
{
var result = await this.entityRepository.GetByMunicipality(municipalityId);

return Request.CreateResponse(HttpStatusCode.OK, result.AsQueryable());
}

[Queryable]
public async Task<IEnumerable<MyEntity>> GetByMunicipality(string municipalityId, ODataQueryOptions options)
{
var result = await this.entityRepository.GetByMunicipality(municipalityId);

return options.ApplyTo(result.AsQueryable());
}

While this one works:

[Queryable]
public async Task<IEnumerable<MyEntity>> GetByMunicipality(string municipalityId)
{
var result = await this.entityRepository.GetByMunicipality(municipalityId);

return result.ToList();
}

Shouldn't they all return the same thing?
Closed Sep 14, 2012 at 7:25 PM by raghuramn

comments

raghuramn wrote Sep 4, 2012 at 11:38 PM

The second one failing is a known issue and there is a bug already tracking it. The issue there is that to bind ODataQueryOptions we need to know the element type of your IQueryable. Task<IEnemurable<T>> is not something we look for. So, we fail.

I am surprised that the first one crashes. I will investigate it.

HongmeiG wrote Sep 6, 2012 at 10:15 PM

We should support Task<IE<Entity>>.

raghuramn wrote Sep 7, 2012 at 3:39 AM

I tried to repro this and could successfully repro the second case which as expected fails. The first case and the third case are working. The second case not working is being tracked by the issue 368 (http://aspnetwebstack.codeplex.com/workitem/368).

Also, looking deeper I found that the $filter that Azzlack is using could trigger a different bug being tracked by 371. May be he was using different queries to test case 1 and case 3. A stack trace would really help here to isolate the issue.

@Azzlack: Could you please provide us with a stack trace for case 1 ?

raghuramn wrote Sep 14, 2012 at 7:24 PM

As mentioned earlier, I could not repro this bug. I have added tests with this commit http://aspnetwebstack.codeplex.com/SourceControl/changeset/730291c5fff0
to verify that this is working.