Get table-data from table-name in LINQ DataContext

Given DataContext context and string tableName, you can just say:

var table = (ITable)context.GetType()
                           .GetProperty(tableName)
                           .GetValue(context, null);

Leave a Comment