Exclude members in nested list by string path #2671
Unanswered
q34hfq34fq5374rqhdf0vih3435dd23234wkklo
asked this question in
Q&A
Replies: 2 comments 5 replies
-
Why don't you use the fluent API (see #1782)? [Fact]
public void Test()
{
var e = new Employee();
e.Should().BeEquivalentTo(new Employee(), opt => opt
.For(employee => employee.roles)
.Exclude(role => role.id));
} |
Beta Was this translation helpful? Give feedback.
5 replies
-
You can use what FA internally uses for solving this with expression trees, firstSource.Should().BeEquivalentTo(secondSource, options => options |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
In this example: https://fluentassertions.com/objectgraphs/#selecting-members you can exclude by path which works for my non-collection members.
How would you exclude the Employee.Role.id in this class:
I have tried:
I still get a message like (meaning the propbery was not excluded):
I am able to get this to work with the some other exclude methods, however I would like to use string-based paths because another library I am using (https://github.com/replaysMike/AnyDiff) can take a collection of strings and it would be nice to be able to use the same collection for both libraries.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions