Try changing your code as follows:
NHibernate.IQueryOver<DataAccess.Domain.Product> query = session.QueryOver<DataAccess.Domain.Product>(); query = query.Where(x => x.Name == "X"); query = query.Take(1).Skip(3); var results = query.List();
Or even better:
var results = session.QueryOver<DataAccess.Domain.Product>() .Where(x => x.Name == "X") .Take(1) .Skip(3) .List();
You can check my code here to download NHibernateQueryOver .
UPDATE:
I think you are missing something. I would advise you to read this article which was really useful to me.
In the paragraph on the Association, they say:
IQueryOver has two types of interests; the type of root (the type of the object returned by the request), and the type of the "current" object to the question. For example, the following query uses a join to create a sub-QueryOver (similar to creating sub-criteria in the ICriteria API):
IQueryOver<Cat,Kitten> catQuery = session.QueryOver<Cat>() .JoinQueryOver(c => c.Kittens) .Where(k => k.Name == "Tiddles");
JoinQueryOver returns a new instance of IQueryOver than its root in the kittens collection. The default type for restrictions is now a kitten (restricting the name "Tiddle" in the above example), when .List () is called, it returns IList. The IQueryOver type inherits from IQueryOver.
This is what I do when I want to create some filters:
Domain.OrderAddress addressDestination = null; Domain.Customer customer = null; Domain.TermsConditionsOfSale termsConditionsOfSale = null; ICriterion filter1 = Restrictions.Where<Domain.Order>(t => t.Company == "MYCOMPANY"); ICriterion filter2 = Restrictions.Where<Domain.Order>(t => t.WareHouseDelivery == "DEPXX"); ICriterion filter3 = Restrictions.Where<Domain.Order>(t => t.Status == "X"); ICriterion filter4 = Restrictions.Where(() => addressDestination.AddressType == "99"); ICriterion filter5 = Restrictions.Where(() => addressDestination.Province.IsIn(new string[] { "AA", "BB", "CC" })); ICriterion filter6 = Restrictions.Where(() => termsConditionsOfSale.ReturnedGoodsCode != "01"); var ordersForProvinces = session.QueryOver<Domain.Order>() .Inner.JoinAlias(t => t.OrderAddresses, () => addressDestination) .Inner.JoinAlias(t => t.Customer, () => customer) .Left.JoinAlias(t => t.TermsConditionsOfSale, () => termsConditionsOfSale); ordersForProvinces .Where(filter1) .And(filter2) .And(filter3) .And(filter4) .And(filter5) .And(filter6); var Results = ordersForProvinces.Skip(50).Take(20).List();
UPDATE-UPDATE:
NHibernate.IQueryOver<Domain.Person> person = session.QueryOver<Domain.Person>(); var myList = DoSomething(person);
Method:
private static IList<Domain.Person> DoSomething(NHibernate.IQueryOver<Domain.Person> persons) { ICriterion filter1 = Restrictions.Where<Domain.Person>(t => t.CompanyName.IsLike("Customer%")); persons.RootCriteria.Add(filter1); var x = persons.Skip(1).Take(3).List(); return (x); }