开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜