开发者

Selecting dynamic types using Linq to SQL

开发者 https://www.devze.com 2023-01-12 20:24 出处:网络
I would like to select from a table using linq to sql without knowing what that table is until runtime, something like

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

精彩评论

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