CustomProperty
他のいくつかのエンティティから使用されるドメイン モデルに1 つのエンティティがあります。
Product
{
int Id;
Collection<CustomProperty> CustomProperties;
}
と
Order
{
int Id;
Collection<CustomProperty> CustomProperties;
}
しかし、DB では、テーブルへの null 許容外部キーと への別の null 許容外部CustomProperty
キーを含む1 つのテーブルだけは必要ありません。代わりに、2 つの別個のテーブルとが必要です。Product
Order
ProductCustomProperty
OrderCustomProperty
自動マッピングと規則でそれを行う必要があります。誰にもアイデアはありますか?
ところで、私にはうまくいかないアイデアがありました。多分誰もが理由の手がかりを持っています:
public class CustomPropertyConvention : IHasManyConvention, IHasManyConventionAcceptance
{
public void Apply(IOneToManyCollectionInstance instance)
{
instance.Table("ProductCustomProperty");
}
public void Accept(IAcceptanceCriteria<IOneToManyCollectionInspector> criteria)
{
criteria.Expect(i => i.Relationship.Class.Name == "CustomProperty" && i.Relationship.EntityType == typeof(Product));
}
}
この例は完全に機能したに違いありませんが、 IOneToManyCollectionInstance.Table() は何も設定していません。