this classes have some similar methods but seems to work slightly different. What's the difference of them and when should I use each of them?
+6
A:
Detached criteria can be built up without reference to an ISession
. You can later take that criteria and apply it to an ISession
to get an executable ICriteria
.
Use ICriteria
when you have a session.
Use DetachedCriteria
when you're not sure against what session the query will be executed.
Note that DetachedCriteria
does not implement ICriteria
-- they are not interchangeable. You must always call detachedCriteria.GetExecutableCriteria(session)
to get an ICriteria
instance.
Jay
2010-09-13 20:43:23
Thanks for the reply, I updated my question, can you check it out?
kilonet
2010-09-13 20:55:47
@kilonet Yes; seems bizarre. If you set a breakpoint on the second one and inspect the value of the local `category` variable, what is it?
Jay
2010-09-14 01:40:19
yep, it was variable naming issue
kilonet
2010-09-14 08:01:47