1

Closed

QueryableAttribute can't work with non-generic collection property

description

Add non-generic collection property to model:
public class ModelClass
{
public CustomerCollection Customers { get; set; }
}
public class CustomerCollection : Collection<Customer>
{
}

ConventionModelBuilder reports following error:

System.ArgumentException occurred
Message=Many to Many navigationProperties must return either List<T> or Collection<T>.
Parameter name: property
Source=System.Web.Http.OData
ParamName=property
StackTrace:
   at System.Web.Http.OData.Builder.NavigationPropertyConfiguration..ctor(PropertyInfo property, EdmMultiplicity multiplicity) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\NavigationPropertyConfiguration.cs:line 29
InnerException:
Closed Oct 18, 2012 at 10:28 PM by hongyes
No longer repro in nightly build

comments

blake05 wrote Sep 13, 2012 at 7:46 PM

I'm using the queryable attribute on controller that returns a queryable but doesn't use EF for the backend... Everything works great until I pass a querystring (v=1) to the controller. Then I get this error.

[Queryable]
public IQueryable<T> Get(){....}

Call the controller with "http://localhost/api/xxx?v=0" and you will get this exception.

We use this query string in conjunction with an (action filter).