Another possibility - can I create some sort of pseudo entity and repoint it at runtime to a different table before executing the query? I would also need to update the mapping of one of the entity fields in that entity to point to a different column name with the table.
Conceptually, I have a primary table P and extension tables E1, E2, ... which are created dynamically by the application based on user definition of custom fields. I'd like to run queries like below. The reason, I'm hesitating to do dynamic SQL is because I have many additional filters on P with LINQ and would like to use LINQ projection capabilities based on P. I only need to use E1, E2... to filter the results...
select *
from P,
join E1 on P.Id = E1.Id
where E1.ABC = 'abc'
or
select *
from P,
join E2 on P.Id = E2.Id
where E2.DEF = 'def'