NHibernate Criteria
Posted
by
Vamsi
on Stack Overflow
See other posts from Stack Overflow
or by Vamsi
Published on 2011-06-30T07:36:35Z
Indexed on
2011/06/30
8:22 UTC
Read the original article
Hit count: 287
nhibernate
|nhibernate-criteria
public class A
{
public string aname {get; set;}
public string aId {get; set;}
public string bId {get; set;}
}
public class B
{
public string bId {get; set;}
public string bname {get; set;}
public string cId {get; set;}
}
public class C
{
public string cId {get; set;}
public string cfirstname {get; set;}
public string clastname {get; set;}
}
public class abcDTO { public string aname {get; set;} public string bname {get; set;} public string clastname {get; set;} }
Evetually the query which I am looking is
SELECT a.aid, b.bname, c.clastname FROM A thisa inner join B thisb on thisa.bid=thisb.bid inner join C thisc on thisb.cid=thisc.cid and this_.POLICY_SEARCH_NBR like '%-996654%'
The criteria which I am trying is, Please let me know the best possible way to write a criteria so that I can get the abcdto object as result
var policyInsuranceBusiness = DetachedCriteria.For() .SetProjection(Projections.Property("a.aid")) .Add(Restrictions.Like("a.aid", "1-SAP-3-996654", MatchMode.Anywhere)) .CreateCriteria("b.bid", "b", JoinType.InnerJoin) .SetProjection(Projections.Property("b.bname")) // ERROR OUT - COULD NOT RESOLVE PROPERTY .CreateCriteria("c.cid", "c", JoinType.InnerJoin) .SetProjection(Projections.Property("c.clastname")); // ERROR - COULD NOT RESOLVE PROPERTY
IList plo = policyInsuranceBusiness.GetExecutableCriteria(_session).SetResultTransformer(NHibernate.Transform.Transformers .AliasToBean();
© Stack Overflow or respective owner