{"action":"created","issue":{"url":"https://api.github.com/repos/OData/WebApi/issues/295","labels_url":"https://api.github.com/repos/OData/WebApi/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/OData/WebApi/issues/295/comments","events_url":"https://api.github.com/repos/OData/WebApi/issues/295/events","html_url":"https://github.com/OData/WebApi/issues/295","id":66950233,"number":295,"title":"$expand does not call the controller","user":{"login":"janhommes","id":3398624,"avatar_url":"https://avatars.githubusercontent.com/u/3398624?v=3","gravatar_id":"","url":"https://api.github.com/users/janhommes","html_url":"https://github.com/janhommes","followers_url":"https://api.github.com/users/janhommes/followers","following_url":"https://api.github.com/users/janhommes/following{/other_user}","gists_url":"https://api.github.com/users/janhommes/gists{/gist_id}","starred_url":"https://api.github.com/users/janhommes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janhommes/subscriptions","organizations_url":"https://api.github.com/users/janhommes/orgs","repos_url":"https://api.github.com/users/janhommes/repos","events_url":"https://api.github.com/users/janhommes/events{/privacy}","received_events_url":"https://api.github.com/users/janhommes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-07T17:46:41Z","updated_at":"2015-10-09T09:03:54Z","closed_at":null,"body":"Is it possible to call the controller on `$expand`? This way you can include authentication on server side and give the developer more control over the $expand function.\r\n\r\nExample:\r\n\r\n`/Product?$expand=Category`\r\n\r\nDoes call the `ProductController` on ...\r\n```\r\n[EnableQuery]\r\npublic IQueryable<Product> Get()\r\n{\r\n    return db.Products;\r\n}\r\n```\r\n... **and also** calls the `CategoryController` Get method with the correct `$filter` query ...\r\n\r\n```\r\n[EnableQuery]\r\npublic IQueryable<Category> Get()\r\n{\r\n    return db.Category;\r\n}\r\n```\r\n... **or** calls the `CategoryController` with a new expand method:\r\n```\r\npublic IQueryable<Category> Expand(object key)\r\n{\r\n    return db.Category.where(x => x.Product.Id == (int)key);\r\n}\r\n```\r\nIf this method is not available, the $expand function can fall back to the normal behavior."},"comment":{"url":"https://api.github.com/repos/OData/WebApi/issues/comments/146806879","html_url":"https://github.com/OData/WebApi/issues/295#issuecomment-146806879","issue_url":"https://api.github.com/repos/OData/WebApi/issues/295","id":146806879,"user":{"login":"alexschrod","id":767490,"avatar_url":"https://avatars.githubusercontent.com/u/767490?v=3","gravatar_id":"","url":"https://api.github.com/users/alexschrod","html_url":"https://github.com/alexschrod","followers_url":"https://api.github.com/users/alexschrod/followers","following_url":"https://api.github.com/users/alexschrod/following{/other_user}","gists_url":"https://api.github.com/users/alexschrod/gists{/gist_id}","starred_url":"https://api.github.com/users/alexschrod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexschrod/subscriptions","organizations_url":"https://api.github.com/users/alexschrod/orgs","repos_url":"https://api.github.com/users/alexschrod/repos","events_url":"https://api.github.com/users/alexschrod/events{/privacy}","received_events_url":"https://api.github.com/users/alexschrod/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T09:03:54Z","updated_at":"2015-10-09T09:03:54Z","body":"I needed similar functionality and wrote a small \"interception\" class that lets you add `.Where(...)` calls onto expanded navigation properties. It's not the solution I wanted (would be nicer to have this built-in), but it serves me well for now. I posted my code on [Stack Overflow](http://stackoverflow.com/questions/32845222/controlling-what-is-returned-with-an-expand-request)."}}