I have some Fluent NHibernate code that runs fine on my local visual studio, but once it gets deployed to a test server I have the following error – one I’ve never come across before:
Unable to cast object of type
‘NHibernate.Impl.DelayedEnumerator1[Core.FileLoad.File]' to type1[Core.FileLoad.File]’.
'Remotion.Linq.QueryableBase
The code that causes this error is:
var files = _readRepository
.Query<File>()
.Where(f => f.Id == fileId)
.ToFuture();
_readRepository
.Query<Record>()
.Where(f => f.File.Id == fileId)
.ToFuture();
var file = files.ToList().First();
Ooops – the code I copied was not the actual code. There was a (Querybase) cast at the start also.
Once I removed that everything worked fine.
Thanks