1

このクラスを考えると:

public class Basket
{
    public int Id { get; set; }
    private string SomeProperty { get; set; }
    private Address Address { get; set; }

    public class BasketMapper : EntityTypeConfiguration<Basket>
    {
        public BasketMapper()
        {
            //ValueType property is simple
            Property(b => b.SomeProperty);

            //Complex type needs all properties mapped
            Property(b => b.Address.Street);
            Property(b => b.Address.City);
            Property(b => b.Address.CountryCode);
        }
    }

}

Addressプロパティを非公開にしたいのですがProperty(b=>b.Address)、クラスがサポートされていないため を使用できません。

Addressパブリック プロパティの場合と同じように、EF に自分のプロパティを複合型としてマップするように指示する簡単な方法はありますか?

私が避けたいのは、 Address のすべてのプロパティを my に追加することBasketMapperです。

4

1 に答える 1