{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1928","repository_url":"https://api.github.com/repos/AutoMapper/AutoMapper","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1928/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1928/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1928/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/1928","id":203865695,"number":1928,"title":"ProjectTo in Queryable throws exception","user":{"login":"Allann","id":2005474,"avatar_url":"https://avatars.githubusercontent.com/u/2005474?v=3","gravatar_id":"","url":"https://api.github.com/users/Allann","html_url":"https://github.com/Allann","followers_url":"https://api.github.com/users/Allann/followers","following_url":"https://api.github.com/users/Allann/following{/other_user}","gists_url":"https://api.github.com/users/Allann/gists{/gist_id}","starred_url":"https://api.github.com/users/Allann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Allann/subscriptions","organizations_url":"https://api.github.com/users/Allann/orgs","repos_url":"https://api.github.com/users/Allann/repos","events_url":"https://api.github.com/users/Allann/events{/privacy}","received_events_url":"https://api.github.com/users/Allann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-29T11:58:23Z","updated_at":"2017-01-29T12:10:00Z","closed_at":null,"body":"I have created a .NET Core webapi that tries to separate the Domain model used by the ORM from the Models presented to the controller and therefore the user of the API.  This works well for single models, but fails when attempting to return IQueryable.  I am unable to return an enumerable because in the real database there are many hundreds of thousand records.\r\nHere is the exception:\r\n```\r\nSystem.Exception: Can't resolve this to Queryable Expression\r\n   at AutoMapper.QueryableExtensions.ExpressionBuilder.ResolveExpression(PropertyMap propertyMap, Type currentType, Expression instanceParameter)\r\n   at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMemberBindings(ExpressionRequest request, TypeMap typeMap, Expression instanceParameter, ConcurrentDictionary`2 typePairCount)\r\n   at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, Expression instanceParameter, ConcurrentDictionary`2 typePairCount)\r\n   at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, ConcurrentDictionary`2 typePairCount)\r\n   at AutoMapper.QueryableExtensions.ExpressionBuilder.<CreateMapExpression>b__5_0(ExpressionRequest tp)\r\n   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)\r\n   at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(Type sourceType, Type destinationType, IDictionary`2 parameters, MemberInfo[] membersToExpand)\r\n   at AutoMapper.QueryableExtensions.ProjectionExpression.To[TResult](IDictionary`2 parameters, IEnumerable`1 memberPathsToExpand)\r\n   at AutoMapper.QueryableExtensions.ProjectionExpression.To[TResult](Object parameters, Expression`1[] membersToExpand)\r\n   at AutoMapper.QueryableExtensions.Extensions.ProjectTo[TDestination](IQueryable source, IConfigurationProvider configuration, Object parameters, Expression`1[] membersToExpand)\r\n   at AutoMapper.QueryableExtensions.Extensions.ProjectTo[TDestination](IQueryable source, Expression`1[] membersToExpand)\r\n   at TestContext.BusinessLogic.Countries.TestContext.Shared.IEntities<TestContext.BusinessLogic.Models.CountryModel>.GetAll() in D:\\Dev\\test\\TestContext\\BusinessLogic\\Countries.cs:line 25\r\n   at TestContext.Controllers.CountriesController.Get() in D:\\Dev\\test\\TestContext\\Controllers\\CountryController.cs:line 21\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext()\r\n\r\n```\r\n\r\nI have attached a zip file with a webapi server project in it that demonstrates the problem.  Run it, and once it's built the database (localdb, see connection string in appsettings), use postman or similar to execute http://localhost:8088/Countries.\r\n\r\n[TestContext.zip](https://github.com/AutoMapper/AutoMapper/files/737479/TestContext.zip)\r\n\r\nTo see it working execute http://localhost:8088/Countries/AU.\r\n\r\nOnce I added the UrlResolver the error started.  However, I know the resolver works because I get a URL in the returned model.  I do not want the user to know the DB Id (Guid) instead using the business key as the surrogate key in the derived URL.\r\n\r\n> dotnet --info\r\n.NET Command Line Tools (1.0.0-preview2-1-003177)\r\n\r\nProduct Information:\r\n Version:            1.0.0-preview2-1-003177\r\n Commit SHA-1 hash:  a2df9c2576\r\n\r\nRuntime Environment:\r\n OS Name:     Windows\r\n OS Version:  10.0.14393\r\n OS Platform: Windows\r\n RID:         win10-x64\r\nVS2015 Update 3"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/275909831","html_url":"https://github.com/AutoMapper/AutoMapper/issues/1928#issuecomment-275909831","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1928","id":275909831,"user":{"login":"lbargaoanu","id":4517428,"avatar_url":"https://avatars.githubusercontent.com/u/4517428?v=3","gravatar_id":"","url":"https://api.github.com/users/lbargaoanu","html_url":"https://github.com/lbargaoanu","followers_url":"https://api.github.com/users/lbargaoanu/followers","following_url":"https://api.github.com/users/lbargaoanu/following{/other_user}","gists_url":"https://api.github.com/users/lbargaoanu/gists{/gist_id}","starred_url":"https://api.github.com/users/lbargaoanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbargaoanu/subscriptions","organizations_url":"https://api.github.com/users/lbargaoanu/orgs","repos_url":"https://api.github.com/users/lbargaoanu/repos","events_url":"https://api.github.com/users/lbargaoanu/events{/privacy}","received_events_url":"https://api.github.com/users/lbargaoanu/received_events","type":"User","site_admin":false},"created_at":"2017-01-29T12:10:00Z","updated_at":"2017-01-29T12:10:00Z","body":"The projection code is executed by the query provider, so you cannot run just any code, only what the DB supports. Maybe passing parameters to ProjectTo would help."}}
{"actor":{"display_login":"lbargaoanu"}}