Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:54:21+00:00 2026-06-05T17:54:21+00:00

What I want to do is to be able to use projections with queryover.

  • 0

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:

 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<TRoot>.List[U]()
 at Tests.Entities.EmployeeFacts.QueryEmployees()

This is my current code:

Employee anEmployee = null;
Contact aContact = null;

session.QueryOver(() => anEmployee).Left
                .JoinAlias(() => anEmployee.Contact, () => aContact)
                .OrderBy(() => aGender.Name).Asc
                .ThenBy(() => aContact.FirstContact).Asc
                .SelectList(builder => builder.Select(() => aContact.FirstContact)
                                              .WithAlias(() => aContact.FirstContact)
                                              .Select(() => anEmployee.FirstName)
                                              .WithAlias(() => anEmployee.FirstName))
                .TransformUsing(Transformers.AliasToBean(typeof(Employee)))
                .List<Employee>();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:54:24+00:00Added an answer on June 5, 2026 at 5:54 pm

    For your select list, all the WithAlias methods should be using the same dto and that should also be the same class used in the transformer. Also, I don’t know why you’d project into a mapped entity? Projections are for flat dto.

    That error you’re seeing is due to the invalid .WithAlias(() => aContact.FirstContact)…NH transformer will now expect a FirstContact property inside the Employee class. Solution is to make a single dto containing FirstContact and FirstName properties and use that for the WithAlias and AliasToBean transformer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to use SwingWorker subclass multiple times. Is this possible?
I want to be able to use $this->__('String to translate') in an external script.
I'm using acts-as-taggable-on in my application and I want to be able to use
I am using the jQuery dialog. I want to be able to use the
I want to be able to use a wildcard in string::find and then fetch
I want to be able to use mklink to create symbolic links on my
I want to be able to use the iPhones Mail.app inside my application so
I want to be able to use Python to open a .csv file like
I want to be able to use the mapfield in the same manner as
I'm developing an XBAP application in C# and want to be able to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.