2009/10/21 aemami <[email protected]>

>
>        public IEnumerable<User> SearchByUserId(int userId)
>        {
>            return session.Linq<User>().Where(user => user.Id ==
> userId);
>        }
>
>
In NH that query doesn't make sense and is strongly not recommended.
That is a simple :
session.Get<User>(userId);
where the UoW come in place etc. etc.

Now try a more complex scenario with a more complex load.
For example load and entity with 3 collections (ISet) in only one
db-round-trip.
Write the query in HQL and put it in the mapping file.
Now use it as:
foreach(var e in sessio.GetNamedQuery("YourQuery").List<YourEntity>())
{
 Console.WriteLine("{0}, {1}, {2}, {3}", e,
e.Collection1.Count, e.Collection2.Count, e.Collection3.Count);
}

Run it 3 times with different sessions.

Let me know which is your result.

-- 
Fabio Maulo

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