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

Join problem with inherited entities #614

Closed
ghost opened this issue Jul 22, 2022 · 9 comments
Closed

Join problem with inherited entities #614

ghost opened this issue Jul 22, 2022 · 9 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jul 22, 2022

  1. Description
    When I try to join on a descendant of a class I got an error:
    x and y are incompatible

While the same in Strongly typed Line works.

  1. Fiddle or Project

Based on the pets and person project:
https://dotnetfiddle.net/eEYaoU

Here is a sample:
I have a simple hierarchy:

public class Samples
{
	public int Id { get; set; }
	public string Name { get; set; }
	public List<Result> Results { get; set; } 
}

public class SoilSamples : Samples
{
	public int Deep { get; set; }
}


public class Result
{
	public int Id { get; set; }
	public int Value { get; set; }
	public Samples Sample { get; set; }
}
@StefH StefH self-assigned this Aug 5, 2022
@StefH
Copy link
Collaborator

StefH commented Aug 5, 2022

Hello @Ibehem,

Thanks for creating this issue.

I did find the issue and I've corrected it. Do you want to test a preview version?

Note that your join is not correct, it should be something like this:

// Arrange
var magnus = new Person { Name = "Hedlund, Magnus" };
var terry = new Person { Name = "Adams, Terry" };
var charlotte = new Person { Name = "Weiss, Charlotte" };

var barley = new Pet { Name = "Barley", Owner = terry };
var boots = new Pet { Name = "Boots", Owner = terry };
var whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
var daisy = new SpecialPet { Name = "Daisy", Owner = magnus, IsSpecial = true };

var people = new List<Person> { magnus, terry, charlotte };
var pets = new List<Pet> { barley, boots, whiskers, daisy };

// Act
var realQuery = people.AsQueryable()
	.Join(
		pets,
		person => person,
		pet => pet.Owner,
		(person, pet) => new { OwnerName = person.Name, Pet = pet.Name });
var realResult = realQuery.ToList();

var dynamicQuery = people.AsQueryable()
	.Join(
		pets,
		"it",
		"Owner",
		"new(outer.Name as OwnerName, inner.Name as Pet)");
var dynamicResult = dynamicQuery.ToDynamicList();

realResult.Should().BeEquivalentTo(dynamicResult);

@EfrSyn
Copy link

EfrSyn commented Aug 5, 2022

Hello Stef, Yes I would love to test a preview version ! And thank you very much for solving this so quickly!
(Ibehem is my personal account), any of them would be fine

@StefH
Copy link
Collaborator

StefH commented Aug 5, 2022

A preview (preview-02) can be downloaded from MyGet:
https://www.myget.org/F/system-linq-dynamic-core/api/v3/index.json

See this link on how to use MyGet:
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

CC: @EfrSyn / @Ibehem

@StefH StefH added the bug label Aug 6, 2022
@StefH
Copy link
Collaborator

StefH commented Sep 9, 2022

Hello @EfrSyn / @Ibehem,

Did you have time to verify if this was solved using that preview version?

1 similar comment
@StefH
Copy link
Collaborator

StefH commented Oct 20, 2022

Hello @EfrSyn / @Ibehem,

Did you have time to verify if this was solved using that preview version?

@StefH
Copy link
Collaborator

StefH commented Oct 28, 2022

Hello @EfrSyn / @Ibehem,

Did you have time to verify if this was solved using that preview version?

2 similar comments
@StefH
Copy link
Collaborator

StefH commented Nov 5, 2022

Hello @EfrSyn / @Ibehem,

Did you have time to verify if this was solved using that preview version?

@StefH
Copy link
Collaborator

StefH commented Nov 24, 2022

Hello @EfrSyn / @Ibehem,

Did you have time to verify if this was solved using that preview version?

@StefH
Copy link
Collaborator

StefH commented Nov 26, 2022

PR merged

@StefH StefH closed this as completed Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants