System.Linq.Dynamic.Core
System.Linq.Dynamic.Core copied to clipboard
create-dynamic-expression-one-to-many-relations-with-child-class-property
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\"")
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\"")
@aysegulgurmeric Can you provide a working fiddle which represents this issue?
The fiddle you provided looks different?
@aysegulgurmeric Can you provide a working fiddle which represents this issue?
The fiddle you provided looks different?