1

以下に示すように、オブジェクト呼び出し 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 に自動参加できません

助けてくれてありがとう

4

2 に答える 2

2

私は彼らのドキュメントに従って問題を見つけたと思います。リストをロードするために不動産業者クラスを作成する必要があります。Petapocoドキュメントのセクション1対多を参照してください。また、不動産業者クラスをより一般的にするこのヘルパークラスOneTOManyも見つけました。

于 2012-11-07T14:10:11.613 に答える