0

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?

twoflower
  • 6,788
  • 2
  • 33
  • 44
  • I doubt that the problem is dependent on the number of records of Entity. It certainly shouldn't be, so if that really is true, it would be good to have complete exception info to debug this. – Oskar Berggren Jan 11 '13 at 09:12

1 Answers1

1

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();
Jamie Ide
  • 48,427
  • 16
  • 81
  • 117