Hi,
I would like to query multiple tables and get the result into my POCO structure.
CatalogRegions table is related to Catalogs table and this one is related to Companies table.
I want to bind my CatalogRegion with the related Catalog and this one with the related Company (catalogRegion.Catalog and catalogRegion.Catalog.Company). catalogRegion.Catalog is ok but catalogRegion.Catalog.Company property is allways null.
Any help?
POCO:
public class Company
{
public Company() { }
public List<Catalog> Catalogs { get; set; }
public int CompanyId {get; set;}
public string Name { get; set; }
}
public class CatalogRegion
{
public CatalogRegion() { }
public int CatalogRegionId { get; set; }
public int CatalogId {get; set;}
public string Name { get; set; }
public Catalog Catalog { get; set; }
}
public class Catalog
{
public int CatalogId {get; set;}
public int CompanyId { get; set; }
public string Name { get; set; }
public Company Company { get; set; }
public List<CatalogRegion> CatalogRegions { get; set; }
}
Query:
CatalogRegion catalogRegion = db.CatalogRegions
.Get(32);
Best regards,
Nuno Ferreira