Вопрос

Invoking the following query when there is no Entity record in the database throws a NotSupportedException

var list = session.Query<Entity>()
                  .OrderBy(x => x.TranslationTime)
                  .Take(10)
                  .Select(x => x.TranslationTime)
                  .ToList();

Removing the Select(x => x.TranslationTime) makes the query be processed fine.

Is there a way to make NHibernate accept the original query even on empty result sets?

Это было полезно?

Решение

The Take(10) method has to come after the Select method:

var list = session.Query<Entity>()
                  .OrderBy(x => x.TranslationTime)
                  .Select(x => x.TranslationTime)
                  .Take(10)
                  .ToList();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top