AutoQueryable
AutoQueryable copied to clipboard
AutoMapper/AutoQueryable/EntityFramework select filtering
Currently I have something that looks like this in my Get Controller API. (I'm using Entity Framework 6, Automapper 7)
_ctx.Person.UseAsDataSource(mapper).For<ViewModel>();
But what happens in the database is that it does a select on each column in the table even if only ask for a couple of items from the URI. I was wondering if there is an optimal way to do this so that only the items that are selected in the URI are selected on in the table:
So for example if I did a URI like this: http//localhost/api/v1/person?select=id,firstname
I would get a query like select [Extent1].id, [Extent1].firstname from Person as [Extent1]
Currently the query looks like this: select [Extent1].id, [Extent1].firstname, [Extent1].lastname, [Extent1].middlename, etc. from Person as [Extent1]