是否可以使用SelectMany()并使其行为像左连接?
我试图将实体对象展平为表格格式,以便我可以将其用作.rdlc报告的数据源.只要有一个子对象,SelectMany()的工作方式就像一个魅力,但我希望看到所有的父对象,无论它是否有子节点.
public class Owner
{
public int ownerID { get; set; }
public string ownerName { get; set; }
public List<Pet> pets { get; set; }
}
public class Pet
{
public int petID { get; set; }
public string petName { get; set; }
public string petType { get; set; }
}
public void GetOwners()
{
List<Owner> owners = new List<Owner>();
owners.Add(new Owner{ownerID=1, ownerName="Bobby", pets = null});
owners.Add(new Owner
{
ownerID = 2,
ownerName = "Ricky",
pets = …Run Code Online (Sandbox Code Playgroud)