Tom Knowlton
asked on
LINQ lambda expression to select from <tablename> where tablename is a variable chosen at runtime?
var query =
(from c in [b]db.productInfo[/b]
where [b]c.flavor[/b] == "Classic Coke" && [b]c.container[/b] == "Can"
select new { c.co2Target }).Single();
Can the parts in bold be decided at runtime?
In other words, I want to use a context.<Table> and use LINQ lambda expression to do a select on the table, but I don't know which table until runtime.
Can I pass in the name of the table as a string into a method, and then inside the method use a lambda expression to do a select on <table name passed in> ? Â Build the lambda expression dynamically?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tom