Thank you for your answer
 but is not working !

 Using nhibernateSession As ISession =
NHibernateSessionFactory.OpenSession()
                listObj = nhibernateSession.CreateCriteria(GetType
(FixedAsset)) _
                .CreateAlias("Category", "c") _
                .SetFetchMode("Category", FetchMode.Eager) _
                .Add(Expression.Sql("c.Name Like 'A%'")) _
                .AddOrder(Order.Asc(Me.GetOrderByCriteria())) _
                .SetResultTransformer(New
DistinctRootEntityResultTransformer()) _
                .List(Of FixedAsset)()
            End Using

this is generated by nhibernate and is not working :
SELECT this_.FixedAssetId as FixedAss1_4_1_, this_.Description as
Descript2_4_1_, this_.ToolNo as ToolNo4_1_, this_.ModifiedBy as
ModifiedBy4_1_, this_.ModifiedDate as Modifie14_4_1_, c1_.CategoryId
as CategoryId8_0_, c1_.NAME as NAME8_0_, c1_.DESCRIPTION as
DESCRIPT3_8_0_
FROM dbo.FA_ListFixedAssets this_
inner join dbo.FA_ListCategory c1_ on this_.CategoryId=c1_.CategoryId
WHERE c.Name Like 'A%' ORDER BY this_.ToolNo asc

How you can see in where clause  c is not replaced with c1_.

Any sugestion ?



On Aug 4, 11:48 pm, dummerchen <[email protected]> wrote:
> You have to use CreateCriteria/CreateAlias to create a subcriteria for
> the associated object:
>
> nhibernateSession.CreateCriteria(GetType(Parent), "p") _
>         .CreateCriteria("p.Child", "c") _
>         .Add(Expression.Sql("c.ChildProperty like '%)) _
>
> --
> Wolfgang
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to