use Expression<Func<T,bool>>

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Mon, Jul 27, 2009 at 9:30 PM, hoofman <[email protected]> wrote:

>
> 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