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

create-dynamic-expression-one-to-many-relations-with-child-class-property #572

Open
aysegulgurmeric opened this issue Feb 25, 2022 · 3 comments
Assignees

Comments

@aysegulgurmeric
Copy link

aysegulgurmeric commented Feb 25, 2022

Is it possible to create a dynamic where condition with a collection property?

I'm trying to filter Parents which Childs.ChildProp1 == "test". What's the correct syntax ?

https://dotnetfiddle.net/Zh7Jy5

public class Parent
{
    public string MasterProp1 { get; set; }
    public string MasterProp2 { get; set; }
    public IEnumerable<Child> Childs { get; set; }  
}


public class Child
{
    public string ChildProp1 { get; set; }
    public int ChildProp2 { get; set; }
}

Parents.Where("Childs.ChildProp1==\"test\"")
@zspitz
Copy link

zspitz commented Feb 26, 2022

Do you want the Parents who have a Child in Childs whose ChildProp1 matches "test"?

Parents.Where("Childs.Any(ChildProp1 == \"test\")")

Or do you want all the Childs whose ChildProp1 matches "test"?

Parents.SelectMany("Childs").Where("ChildProp1 == \"test\"")

@StefH
Copy link
Collaborator

StefH commented Jun 4, 2023

@aysegulgurmeric Can you provide a working fiddle which represents this issue?

The fiddle you provided looks different?

@StefH StefH self-assigned this Sep 10, 2023
@StefH
Copy link
Collaborator

StefH commented Sep 10, 2023

@aysegulgurmeric Can you provide a working fiddle which represents this issue?

The fiddle you provided looks different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants