I am using EF Core and stuck in a scenario where I need to fetch all the Parent table records that has child records matching the given child records. Example:
Parent Table
| Id | Name |
|---|---|
| 1 | P1 |
| 2 | P2 |
| 3 | P3 |
Child Table
| Id | ParentId | Name | Age | Address |
|---|---|---|---|---|
| 1 | 1 | C1 | 20 | abc |
| 2 | 1 | C2 | 25 | xyz |
| 3 | 2 | C1 | 20 | qqq |
| 4 | 2 | C2 | 25 | wer |
| 5 | 3 | C3 | 30 | tyu |
I need Linq to get all parents which matches below search parameters.
All prents with Child records same as: Child: [ {C1,20}, {C2,25}]
So, it should return the Parent P1 and P2 as result. I am trying EqualityComparer but getting not translated error from EF. Any help is appreciated.