Try fast search NHibernate

29 June 2009

Criteria on NH3.0.0

This is how will look the Criteria in NH3.0.0 (the actual trunk)

IList<Student> sudents =
session
.QueryOver<Student>()
.Where(s => s.Name == "Fabio").And(s => s.StudentNumber > 100)
.List();

We will work to allow

IList<Student> sudents =
session
.QueryOver<Student>()
.Where(s => s.Name == "Richard" && s.StudentNumber > 100)
.List();

The intention, so far, is have lot of features (may be not all) available with the actual implementation of Criteria but avoiding strings and having a more readable sentence.

Richard Brown, PL of nhibernatelambda, is working on it.

10 comments:

  1. Very cool! Readability like linq but with the power of nh. So this gives us things like Fetch.Join in a linq like language!

    ReplyDelete
  2. Is this a breaking change?
    Will be the old condition API still be available?

    ReplyDelete
  3. Great, cool!
    Bbut and the NHibernate.Linq??

    ReplyDelete
  4. Linq can't support all we are supporting in NH.
    As example try to set the cache behaviour of a Linq query, or try to use a value mapped to private field, or create a criteria of a dynamic-entity... and so on.

    ReplyDelete
  5. Is true Fabio... great job!

    Where can i download NH3 Preview? hehehe :)
    I'm excited for use this new resource :P

    ReplyDelete
  6. QueryOver seems kinda weird to me... not sure what Over is trying to convey. I think just Query would work... or what is wrong with just session.Get<Student>()
    .Where() ...

    ReplyDelete
    Replies
    1. I agree. Not sure what the "Over" is implying. "Query" actually already exists, so maybe there's a backward compatibility issue so maintained for those that prefer the LInQ interface (less functional perhaps, but simpler - if not, why not just replace "Query" if so much better/as simple). I like "Get(..." even better tho; heck, the purpose of an ORM layer is to abstract away the db layer; this is a good step toward that end. But, it just shows how much of a leaky abtraction ORMs are; the commands/sequences/idioms are still DRIPPING with db/relational algebra-related concerns; we haven't moved an inch from it.

      Delete
  7. var query = session.QueryOver()
    .Where(e=>(string)e.Pool.Id == kodePool && e.JobTitle.JobPosition.Dummy)
    .List();

    Error ini e.JobTitle.JobPosition.Dummy => invalid property.

    ReplyDelete
  8. i am getting an error can you suggest a solution for this---Unable to perform find[SQL: SQL not available] --exception

    ReplyDelete