Can anyone point out why this might happen:
I use NHibernate and Linq for this provider.
The code is not specified here:
var sequence = session.Query<T>(); var wtfSequence = sequence.Where(x => true); var okaySequence = sequence.Where(x => x.Id > 0);
Debugging shows that the sequence (which is an IQueryable<T> ) after that contains 2 elements that have been added to the database.
I expect the first Where statement to return all elements from this sequence, but unfortunately it leaves 0 elements.
(why???)
The second Where statement, in contrast, actually gives 2 elements, since it should work.
The following are NHibernate -> Sqlite for the first and second Where statements.
NHibernate: select cast(count(*) as INTEGER) as col_0_0_ from "BinaryUnitProxy_IndicatorUnitDescriptor" binaryunit0_ where @p0='true';@p0 = 'True' [Type: String (0)] NHibernate: select cast(count(*) as INTEGER) as col_0_0_ from "BinaryUnitProxy_IndicatorUnitDescriptor" binaryunit0_ where binaryunit0_.Id>@p0;@p0 = 0 [Type: Int32 (0)]
Now, if I test the same code with my InMemoryRepository , which stores each object in a simple list, (x => true) works fine with absoluteness.
So - why does this happen when using NHibernate ? Is this a mistake, or am I doing something wrong?
Thanks.
c # lambda linq nhibernate iqueryable
Yippie-ki-yay
source share