EntitySetController currently returns an IQueryable<T> for its Get() function. When supplying the $select query, it'll throw an ArgumentException stating that it is unable to convert the SelectExpandWrapper to IQueryable.
I suppose the function should be changed to return an IEnumerable instead and set the QueryableAttribute on it.
I also think the functions that return T should be adapted to utilize SingleResult<T>?
Comments: Looking at it again, I found the problem is a little bit different. The problem lies with the QueryableAttribute afterall not with the IQueryable. It just seemed that way due to the error and my test case which contained a minor mistake; the function that returned IQueryable had the attribute with PageSize set while I only set the attribute on the function that returned IEnumerable. Forgot to set the PageSize on that one hence IEnumerable worked. Anyhow here is some code: ``` namespace TestAPI.Controllers { public class BlacklistController : EntitySetController<Blacklist, int> { private readonly StrategoEntities db = new StrategoEntities(); //Works public override IQueryable<Blacklist> Get() { return db.Blacklists; } [Queryable] public IQueryable<Blacklist> All() { return db.Blacklists; } //Doesn't work: // System.ArgumentException // Object of type 'System.Data.Entity.Infrastructure.DbQuery`1[System.Web.Http.OData.Query.Expressions.SelectExpandWrapper`1[Entities.Blacklist]]' // cannot be converted to type 'System.Linq.IQueryable`1[Entities.Blacklist]'. [Queryable(PageSize=5)] public IQueryable<Blacklist> PropertySet() { return db.Blacklists; } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } } } ```
I suppose the function should be changed to return an IEnumerable instead and set the QueryableAttribute on it.
I also think the functions that return T should be adapted to utilize SingleResult<T>?
Comments: Looking at it again, I found the problem is a little bit different. The problem lies with the QueryableAttribute afterall not with the IQueryable. It just seemed that way due to the error and my test case which contained a minor mistake; the function that returned IQueryable had the attribute with PageSize set while I only set the attribute on the function that returned IEnumerable. Forgot to set the PageSize on that one hence IEnumerable worked. Anyhow here is some code: ``` namespace TestAPI.Controllers { public class BlacklistController : EntitySetController<Blacklist, int> { private readonly StrategoEntities db = new StrategoEntities(); //Works public override IQueryable<Blacklist> Get() { return db.Blacklists; } [Queryable] public IQueryable<Blacklist> All() { return db.Blacklists; } //Doesn't work: // System.ArgumentException // Object of type 'System.Data.Entity.Infrastructure.DbQuery`1[System.Web.Http.OData.Query.Expressions.SelectExpandWrapper`1[Entities.Blacklist]]' // cannot be converted to type 'System.Linq.IQueryable`1[Entities.Blacklist]'. [Queryable(PageSize=5)] public IQueryable<Blacklist> PropertySet() { return db.Blacklists; } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } } } ```