I am using Linq for my queries and would like to be able to get a list of properties I want returned in the "select" portion using reflection. I've tried the following to no avail:
string[] paramList = new[]{"AppId","Name"};
var query =
from entity in
_ctx.App
select new {entity.GetType().GetProperties().Where(prop=>paramList.Contains(prop.Name) )};
What am I missing here?
When working with reflection inside a EF query you would need to write the expression yourself. Look at these existing question for more information
The problem is not Linq itself, but because your query is parsed into an Expression Tree which Entity Framework doesn't understand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With