0

たとえば、広告 Web サイトに共通のフィールドと特定のフィールドがある場合、Entity Framework を使用して TPH ベースのエンティティを開発するための最良のアプローチは何ですか。

public class Ad
{
    // Primary properties
    public int Id { get; set; }
    public string Title { get; set; }
    public string TitleStandard { get; set; }
    public string Version { get; set; }
    public string VersionStandard { get; set; }
    public int Year { get; set; }
    public decimal Price { get; set; }

    // Navigation properties
    public Color Color { get; set; }
    public Member Member { get; set; }
    public Category Category { get; set; }
    public IList<Feature> Features { get; set; }
    public IList<Picture> Pictures { get; set; }
    public IList<Operation> Operations { get; set; }
}

public class AdCar : Ad
{
    public int Kms { get; set; }
    public Model Model { get; set; }
    public Fuel Fuel { get; set; }
}

public class AdBoat : Ad
{
    public int Hours { get; set; }
    public string Model { get; set; }
}

サブクラスごとに特定の操作を作成する必要がありますか?

  • CreateAdCar()
  • CreateAdBoat()

または、次のようなものを使用できますか:

  • CreateAdCommon()CreateAdCar()

Car Ad クラスと Boat Ad クラスのすべてのコードを繰り返す必要がないように、2 つのクラスを分割するにはどうすればよいですか?

4

0 に答える 0