Selecting dynamic types using Linq to SQL
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, b开发者_开发知识库ut I was wondering if there was a way to do this.
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.
精彩评论