开发者

Define a list type into a variable

Hello everybody I have a LINQ declaration like this :

var query = from foo in NHibernate_Helper.session.Linq<TheType>() select foo;

Is it possible to store TheType into a variab开发者_JAVA技巧le to dynamically define this one ?

Thank you by advance


This doesn't do exactly what you asked, but can you just make your method generic?

public IEnumerable<T> GetSomething<T>()
{
    return (from foo in NHibernate_Helper.session.Linq<T>() select foo);
}
...
GetSomething<TheType>();


No, generic types must be known at compile time.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜