Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IIsEntityDecider to use ExpressionsHelper.TryGetMappedType #2324

Merged
merged 3 commits into from
Apr 26, 2020

Conversation

maca88
Copy link
Contributor

@maca88 maca88 commented Mar 6, 2020

Extracted from #2316 and will allow the following query to work:

db.Query<Animal>().Select(o => o.FatherOrMother.SerialNumber).ToList();

// Not mapped property
public Animal FatherOrMother => Father ?? Mother;

The current logic detects FatherOrMother as a mapped property and a join is added, which prevents #2316 from support the above query. By using ExpressionsHelper.TryGetMappedType prevents FatherOrMother to be detected as a mapped property.

Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case for the kind of query this change allows support?

src/NHibernate/Linq/Visitors/WhereJoinDetector.cs Outdated Show resolved Hide resolved
@maca88
Copy link
Contributor Author

maca88 commented Apr 20, 2020

Can you add a test case for the kind of query this change allow support?

By just updating IIsEntityDecider the mentioned query in the first post does not execute, because SelectClauseHqlNominator will still nominate the not mapped property as evaluatable. With the last commit I added a simple fix for SelectClauseHqlNominator issue and a test case.

Co-Authored-By: Frédéric Delaporte <12201973+fredericDelaporte@users.noreply.github.com>
@fredericDelaporte fredericDelaporte added this to the 5.3 milestone Apr 22, 2020
@fredericDelaporte fredericDelaporte merged commit 6b71ce6 into nhibernate:master Apr 26, 2020
@maca88 maca88 deleted the IsEntityDecider branch April 26, 2020 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants