2

I would like to select from a table using linq to sql without knowing what that table is until runtime, something like

Type t = Type.GetType(myString);
var results = from o in context.t select o;

Obviously this doesn't work, but I was wondering if there was a way to do this.

1 Answer 1

2

Well, you can use DataContext.GetTable(Type). That returns an ITable. Without knowing more about what you're trying to do, that's the closest we can really come to answering... if you can give more detail, we may be able to help you more.

Sign up to request clarification or add additional context in comments.

1 Comment

Yea, sorry for being an idiot. I hadn't referenced the System.data.linq assembly yet in my WCF project, so I was only getting table names as properties off my context instantiation and wasn't thinking clearly to realize my intellisense wasn't showing everything. Thanks for the response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.