Note that there are some explanatory texts on larger screens.

plurals
  1. PONhibernate queryover projection on detail entity fields
    primarykey
    data
    text
    <p>What I want to do is to be able to use projections with queryover. I have succeeded doing this using projections on first level only using AliasToBean Transformer but when i project on properties from a detail class nhibenate throws the following exception:</p> <pre><code> Could not find a setter for property 'FirstContact' in class 'Model.Personnel.Entities.Employee' at NHibernate.Properties.ChainedPropertyAccessor.GetSetter(Type theClass, String propertyName) at NHibernate.Transform.AliasToBeanResultTransformer.TransformTuple(Object[] tuple, String[] aliases) at NHibernate.Loader.Criteria.CriteriaLoader.GetResultList(IList results, IResultTransformer customResultTransformer) at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) at NHibernate.Impl.CriteriaImpl.List(IList results) at NHibernate.Impl.CriteriaImpl.List[T]() at NHibernate.Criterion.QueryOver`1.List[U]() at NHibernate.Criterion.QueryOver`1.NHibernate.IQueryOver&lt;TRoot&gt;.List[U]() at Tests.Entities.EmployeeFacts.QueryEmployees() </code></pre> <p>This is my current code:</p> <pre><code>Employee anEmployee = null; Contact aContact = null; session.QueryOver(() =&gt; anEmployee).Left .JoinAlias(() =&gt; anEmployee.Contact, () =&gt; aContact) .OrderBy(() =&gt; aGender.Name).Asc .ThenBy(() =&gt; aContact.FirstContact).Asc .SelectList(builder =&gt; builder.Select(() =&gt; aContact.FirstContact) .WithAlias(() =&gt; aContact.FirstContact) .Select(() =&gt; anEmployee.FirstName) .WithAlias(() =&gt; anEmployee.FirstName)) .TransformUsing(Transformers.AliasToBean(typeof(Employee))) .List&lt;Employee&gt;(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload