Given I have a simple object like this
public class TestA
{
public int TestAId { get; set; }
public string Description { get; set; }
public IEnumerable<TestB> TestBCollection { get; set; }
}
public class TestB
{
public int TestBId { get; set; }
public int FkTestAId { get; set; }
public string Description { get; set; }
}
List<TestA> a = new List<TestA>()
{
new TestA()
{
TestAId = 1,
Description = "Test A Description",
TestBCollection = new List<TestB>()
{
new TestB()
{
TestBId = 10,
FkTestAId = 1,
Description = "Test B Description" // this must be used because of the matching FK
}
}
}
};
I am trying to Select the description property on TestA but if there is a value in TestB where TestAId == FkTestAId I want to select TestB Description