C# – HQL vs Linq to objects

asp.netclinqnhibernate

I need to get the products in the system that match certain criteria.

How should i decide if I should write an HQL and get all products that match the criteria from DB or write a Linq query directly to the main List that contain all products in the system.

Which should be better performance vise

Best Answer

An NHibernate query would be better because the filtration of the objects would happen in the database. Using LINQ to Objects you would most likely be returning objects from the database that you don't really want.

Always filter result-sets in the database if you can - this will give you the best performance possible (all other things being equal).