NHibernate:查询未映射实体时的意外行为

NHibernate:查询未映射实体时的意外行为,nhibernate,exception,Nhibernate,Exception,我有一个封装Nhibernate会话的通用存储库类: public class Repository<T>{ public IQueryable<T> GetAll(){ return this.Session.Query<T>(); } } 这是正常的行为还是我对NH的理解有误?是否有方法覆盖此行为?LINQ实现是Criteria API和此问题的包装,并标记为“不会修复”。Fabio Maulo的评论指出,验证类是否映射对性能影响太大 这对

我有一个封装Nhibernate会话的通用存储库类:

public class Repository<T>{

public IQueryable<T> GetAll(){

    return this.Session.Query<T>();
}

}

这是正常的行为还是我对NH的理解有误?是否有方法覆盖此行为?

LINQ实现是Criteria API和此问题的包装,并标记为“不会修复”。Fabio Maulo的评论指出,验证类是否映射对性能影响太大


这对我来说也是新闻,起初我认为这是由于LINQ延迟执行。

NH-LINQ是CriteriaAPI的包装器。由于NH3.0,LINQ提供程序基于HQL引擎。另一点是,可以执行例如.Query(),并且查询将包括所有映射的子类。
 private static Configuration BuildNHibernateConfig(Action<IDbIntegrationConfigurationProperties> dbIntegration)
        {
            var configuration = new Configuration();

            configuration
                .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                .DataBaseIntegration(db =>
                {

                    db.ConnectionString = connectionString.Value;
                    db.Dialect<MsSql2008Dialect>();

                })
                .AddAssembly(typeof(ActionConfirmation<>).Assembly)
                .SetProperty("show_sql", "true")

                .CurrentSessionContext<LazySessionContext>();

         //   var mappings = GetMappings();
         //   configuration.AddDeserializedMapping(mappings, "Hydra");

            return configuration;
        }

        private static HbmMapping GetMappings()
        {
            var mapper = new ModelMapper();
            mapper.AddMapping<FacilityMap>();
            return mapper.CompileMappingForAllExplicitlyAddedEntities();

        }