I have an object call Country and another call CounytryRegions as express below
[TableName("Countries"),
PrimaryKey("Code", autoIncrement = false)]
public class Country
{
public Country()
{
this.CountryRegions = new List<CountryRegion>();
}
public string Code { get; set; }
public string Name { get; set; }
[Foliaco.DataAccess.ResultColumn()]
public List<CountryRegion> CountryRegions { get; set; }
}
[TableName("CountryRegions"),
PrimaryKey("Code", autoIncrement = false)]
public class CountryRegion
{
public CountryRegion()
{
this.Country = new Country();
}
public string Code { get; set; }
public string Name { get; set; }
public string CountryCode { get; set; }
[Foliaco.DataAccess.ResultColumn()]
public Country Country { get; set; }
}
If I execute the sql below
Country country = this.DB.Fetch<Country,CountryRegion>("select * from dbo.countries c join dbo.countryregions cr on c.Code = cr.CountryCode where c.Code = @0","US").FirstOrDefault();
I'm expecting to get on the CountryRegions property of the Country class all the associated records to that country, but instead I getting the get following Error
Can't auto join CountryRegion
Thanks for the help
I think I found the problem according with their documentation I need to crated a Realtor Class to load the list refer to section One to Many on the Petapoco Documentation, I've also found this helper class OneTOMany that makes the Realtor class more generic