I am using NHibernate in my project and I need to get all of the values in a table for a specific type (of domain model) and the type is variable.
I can use the criteria to do criteria.List() but the problem is that the type is variable and passed to me at run time so I need to be able to specify a type that is n开发者_运维知识库ot constant and get all of the values in that table according to the NHibernate mappings.
Is this possible?
You could try one of the following:
session.CreateCriteria(type).List(results);
session.CreateQuery("from " + type.Name).List(results);
精彩评论