We have a new requirement where we need to dynamically fetch a list of columns from a table. We have 141 columns in this table, but say we only want to return 2 or 3 of them, we just don't know which 3 until run-time.
These columns are passed in as a List<string>
, with the hopes I could use reflection to access the property on the source object.
We have support for this already by being able to pass a TObjectDto
into our service which our IQueryable
is projected to before hitting the database, it just doesn't handle the dynamic columns part of the equation.
So far I have unable to do something similar using MapFrom (no luck because reflection is not supported in LINQ, and it must be LINQ because otherwise it's not supported by queryable)
http://docs.automapper.org/en/stable/Queryable-Extensions.html#supported-mapping-options
Is there any reason I should keep going down this rabbit hole and instead just use what I have to generate some raw SQL?