Is there a way that I can access a LINQ property dynamically using a variables value without reflection in vanilla C#? I believe there are some libraries that could assist in this (such as System.Linq.Dynamic), but I would like to avoid a dependency if possible. In pseudo, something that functions like this:
var temp = "PropertyName";
context.Table.Where(a => a.GetProperty(temp) > 5);
I initially tried a solution like this using reflection, which worked perfectly when I was testing it with regular LINQ. However it doesn't work with a LINQ-to-Entity object, since EF can't compile that into SQL. I also looked into expression trees, but that didn't seem like the way to go for just the property accessing capabilities (and some of my "Where" conditions are going to be dynamically generated).
If anyone has any ideas / examples on this, I'd appreciate it!