Having fallen behind in the world of ORM and modern data access, I'm looking to move away from DataSets (shudder) and into a proper mapping framework.
I've just about got my head around Linq to SQL, an I'm now looking into NHibernate with the view to using it in our next project.
With old school sql and data sets, your sql queries obviously only return the data you want. I also understand that L2S is also clever enough to evaluate its where clauses so that it only ever returns the objects you requested. Is NHibernate the same? And is it the same with Ayende's Linq to NHibernate?
By this i mean, if i do the equivalent of:
Select * from customers where name = "fred"
will it fetch every customer into memory, and then filter out the non-freds, or is it clever enough to only get what it needs in the first place?
If it is intelligent, what are the caveats? Are there certains types of query which cannot be evaluated in this way? What performance issues do i need to be aware of?
Thanks
Andrew
A quick answer is that the ORM will check the property name and will transform it to a SQL query that will do you name = .... So it won't load all the customers into the memory to search for the name.
Nhibernate comes with a couple of different ways to query the database. Hibernate uses a Sql like syntax called HQL, which is SQL on objects. Also it can do a search by example, where you create an object and fill in the critea you want, then hibernate will pull the object out of the DB which have the same property values.
have a look here it will get you up to speed summer of Nhibernate lession 2 and 2a will answer in more depth
HTH
bones
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With