I have a method that takes a parameter of SqlExpression<T>. The method basically takes an OrmLite query and performs some queries on it generated from a string input.
I really need to be able to get all table types for the query from SqlExpression<T> so I can generate an expression.
In the debugger I can see main table and joined tables are in a protected property called tableDefs but I cannot see any public accessor.
I can get via reflection:
public static class SqlExpressionExtension
{
public static List<Type> GeTableTypes<T>(this SqlExpression<T> query)
{
return ((List<ModelDefinition>)query.GetType().GetField("tableDefs", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(query))
.Select(x => x.ModelType).ToList();
}
}
But I think would be better using public accessor.
Is there a proper way to get all table types from a SqlExpression<T>?