Hi, I'm not able to do something like this
select * from A where A.Id in (select id from B)
I have:
TABLE Job
int IdJob
TABLE JobPerson (association table)
int IdJob
int IdPerson
I need all jobs made by requestedPerson (this person has IdPerson=2).
I need to build the query with criteria. I tried this:
DetachedCriteria subquery = DetachedCriteria.For(typeof(JobPerson));
subquery.Add(Expression.Eq("IdPerson", requestedPerson.IdPersonGet));
subquery.SetProjection(Projections.Property("IdJob"));
ICriteria critMain = session.CreateCriteria(typeof(Job));
critMain.Add(Subqueries.In("IdJob", subquery));
IList jobs = critMain.List();
But it result to exception: {"Failed to convert parameter value from a String to a Int32."}
{"could not execute query
[ SELECT this_.IdJob as IdJob11_0_, this_.Name as Name11_0_, this_.IdPath as IdPath11_0_, this_.IdPersonHolder as IdPerson4_11_0_, this_.IdPersonHolderHistory as IdPerson5_11_0_ FROM Job this_ WHERE ? in (SELECT this_0_.IdJob as y0_ FROM JobPerson this_0_ WHERE this_0_.IdPerson = ?) ]
Positional parameters:
0 IdJob
0 2
[SQL: SELECT this_.IdJob as IdJob11_0_, this_.Name as Name11_0_, this_.IdPath as IdPath11_0_, this_.IdPersonHolder as IdPerson4_11_0_, this_.IdPersonHolderHistory as IdPerson5_11_0_ FROM Job this_ WHERE ? in (SELECT this_0_.IdJob as y0_ FROM JobPerson this_0_ WHERE this_0_.IdPerson = ?)]"}
What did I wrong???
|