Click to See Complete Forum and Search --> : NHibernate - where clause include result from a STORED PROC


THY02K
April 22nd, 2009, 07:04 AM
NHibernate - where clause include result from a STORED PROC?

I have this stored procedure "spIsAuthorized" with an OUT param "IsAuthorized" of type CHAR (Y=yes authorized and N=not authorized)

Now my question is, without access control checking I normally load the objects using ICriteria/or/IQuery


IQuery oQuery.SetMaxResults(nMaxResults);
IList lstResult = oQuery.List();
...
OR
...
ICriteria oCriteria.SetMaxResults(nMaxResults);
IList lstResult = oCriteria.List();


Now how do I filter (add to oCriteria or where-clause of oQuery) so that only those authorized is returned? Basically I want to do something like this:


oCriteria.Add( Expression.Eq("spIsAuthorized", "UserId=123,ActionId=2", "Y") )


* spIsAuthorized=stored proc
* UserId and ActionId are input param to stored proc
* Y = output param of stored proc, "IsAuthorized".

Thanks!