I am trying to use LINQ to NHibernate (1.0 GA, NH 2.1.0.4) in a
generic repository.  My repository looks like this

class Repository<T> {
    public T FindOne(Func<T, bool> predicate) {
        return Session.Linq<T>().SingleOrDefault(predicate);
    }
}

And a client calls the method like this

new Repository<User>().FindOne(u => u.UserName == "user_name");

The code works except the resulting SQL never has a where clause.
However, there is a resulting where clause if the client gets a
session and bypasses my repository like this

Session.Linq<User>().SingleOrDefault(u => u.UserName == "user_name");

Why does passing the predicate to a method result in the predicate
logic never making it into the SQL?  (Apologies if this question isn't
NH specific)

Thanks for your help.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to