I want to build dynamic linq.
But I want to dynamically set the table (from clause)
Is this possible?
Malcolm
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As always, it depends ;-p
If you want to use the LINQ extension methods or query syntax, then no: this is tightly coupled to
IQueryable<T>, whereTis the source type. Generics might be an option, depending on the scenario:The above could be made to work with LINQ-to-SQL, for example, by using
GetTable<T>()(and specially hand-crafted data objects). Of course, to get from a string to generics you’d have to use reflection (MakeGenericMethod) – so not trivial!Can you clarify the exact scenario here?
It sounds like maybe you should just use a regular command here… for example, perhaps with ExecuteQuery, which takes a string command and loads the data into typed objects.