I'm working with NHibernate and need to retrieve and process up to 2 million rows. Ideally, I could process each row - one at a time - without NHibernate loading all 2 million in memory at once (because, you know, that hurts).
I'd prefer to get an IEnumerable which would call the data reader iteratively for each read so I could process the data read - then discard it. By doing it this way I save a boatload of memory, and begin processing results far faster. I could also improve performance through multithreading and/or the use of PLinq.
Is this possible with NHibernate's ICriteria? Everything it returns seems to be IList, and fully loaded before handing the collection reference off. Why IList instead of IEnumerable?!
I don't mean "lazy" in the traditional sense that NHibernate uses with regards to loading child or parent objects. I want a lazy IEnumerable meaning someway of getting a IEnumerable from an ICriteria object. ICriteria only has a List() method which loads the results in an ArrayList.
ICriteria doesn't have any methods that return an IEnumerable, but IQuery does.
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