Search code examples
nhibernatenhibernate-projections

nHibernate QueryOver Projects - are Select and Where the same thing?


Using nHibernate QueryOver, if I want to enforce a projection for performance, are "Select" and "Where" the same thing? In other words, will ..

        var member = session.QueryOver<Member>()
            .Select( projections => projections.Email == model.Email )
            .Take(1).SingleOrDefault();

Run the same as

        var member = session.QueryOver<Member>()
            .Where( context => context.Email == model.Email )
            .Take(1).SingleOrDefault();

Or is there a difference in the two?


Solution

  • Select projects (you could also say maps); Where filters. This is the same as SQL and all LINQ providers (and QueryOver is also sort of a LINQ provider). It seems that in this case you want to filter, not project, so you need Where