Given DataContext context
and string tableName
, you can just say:
var table = (ITable)context.GetType()
.GetProperty(tableName)
.GetValue(context, null);
More Related Contents:
- Returning IEnumerable vs. IQueryable
- Return anonymous type results?
- How can I conditionally apply a Linq operator?
- LINQ to SQL – Left Outer Join with multiple join conditions
- How to do a subquery in LINQ?
- Understanding .AsEnumerable() in LINQ to SQL
- TransactionScope vs Transaction in LINQ to SQL
- LINQ: combining join and group by
- How to write Asynchronous LINQ query?
- Am I misunderstanding LINQ to SQL .AsEnumerable()?
- How do you perform a CROSS JOIN with LINQ to SQL?
- LINQ Where Ignore Accentuation and Case
- Operation could destabilize the runtime?
- How to select only the records with the highest date in LINQ
- Linq query with nullable sum
- Custom Method in LINQ to SQL query
- LINQ to SQL using GROUP BY and COUNT(DISTINCT)
- LINQ Expression to return Property value?
- Max or Default?
- Will using LINQ to SQL help prevent SQL injection
- How do I do a left outer join with Dynamic Linq?
- Get sum of two columns in one LINQ query
- Last and LastOrDefault not supported
- Linq “Could not translate expression… into SQL and could not treat it as a local expression.”
- Accessing System Databases/Tables using LINQ to SQL?
- LINQ to SQL Where Clause Optional Criteria
- Linq where column == (null reference) not the same as column == null
- Is Injection Possible through Dynamic LINQ?
- If Else in LINQ
- C# Linq to SQL: How to express “CONVERT([…] AS INT)”?