以下に示すように、オブジェクト呼び出し Country と別の呼び出し CounytryRegions があります
[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; }
}
以下のSQLを実行すると
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();
Country クラスの CountryRegions プロパティで、その国に関連付けられているすべてのレコードを取得することを期待していますが、代わりに次のエラーを取得します
CountryRegion に自動参加できません
助けてくれてありがとう