Joining two unrelated view-tables with nhibernate and ICriteria

前端 未结 1 1612
生来不讨喜
生来不讨喜 2020-12-22 12:13

I have two entities based on two views. The mappings looks like this:

Entiy A:



        
相关标签:
1条回答
  • 2020-12-22 12:22

    In scenarios whithout explicit mapping between our entities, we can use only HQL.

    • 14.2. The from clause (small cite and snippet)

    Multiple classes may appear, resulting in a cartesian product or "cross" join.

    from Formula, Parameter
    from Formula as form, Parameter as param
    

    So in the case above we would have HQL like this:

    FROM SearchView AS sv, SearchInvoiceResourceLookUpView AS srf
    WHERE srf.InvoiceId = sv.Id
    AND srf.ResourceId = '[Inser resource id here]'
    

    Also some SELECT should be used and maybe DTO with Result Transformer...

    0 讨论(0)
提交回复
热议问题