views:

23

answers:

1

Hi,

What is IDetachedQuery and its difference with DetachedCriteria? How and when IDetachedQuery is used?

UPDATE:

I'm using NHibernate 2.1.2.4000

+1  A: 

IDetachedQuery is an interface implemented by DetachedQuery and DetachedNamedQuery.

DetachedQuery is like DetachedCriteria, but for HQL queries. DetachedNamedQuery is for named queries.

As far as I know you don't use the interface directly. Example of DetachedQuery:

var deleteQuery = new DetachedQuery("DELETE FROM myObject o WHERE o.Id = IN (:idList)")
                            .SetParameterList("idList", list);
deleteQuery.GetExecutableQuery(session).ExecuteUpdate();
Mauricio Scheffer