gpt4 book ai didi

c# - 设置继承以避免将来代码冗余的最佳方法是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:50 25 4
gpt4 key购买 nike

<分区>

我有 7 个类(class):

public class Entity
{
public int Id { get; set; }
}

public class Product : ????
{
// Contructor
public Product()
{
Photos = new HashSet<PhotoSource>();
ProductFeatures = new HashSet<ProductFeature>();
}

// Primitives
public string ProductName { get; set; }
public string InternalSKU { get; set; }
public string ModelNumber { get; set; }
public string Description { get; set; }
public int QtyPerUnit { get; set; }
public double UnitPrice { get; set; }
public int UnitsInStock { get; set; }
public int UnitsOnOrder { get; set; }
public int? ReOrderLevel { get; set; }
public string Warranty { get; set; }

// Foreign Keys
public int SubCategoryID { get; set; }
public int VendorId { get; set; }

// Navigation Properties
// Classes
[ForeignKey("SubCategoryID")]
public virtual SubCategory SubCategory { get; set; }
[ForeignKey("VendorId")]
public virtual Vendor Vendor { get; set; }

// Collections
public virtual ICollection<PhotoSource> Photos { get; set; }
public virtual ICollection<ProductFeature> ProductFeatures { get; set; }
}


public class ProductSeasonal : ????
{
// Primitives
public int? OffSeasonDiscount { get; set; }
public DateTime SeasonStartDate { get; set; }
public DateTime SeasonEndDate { get; set; }
public int? QtyLimitedTo { get; set; }
}

public class ProductDiscontinued : ????
{
// Primitives
public DateTime DiscontinuedDate { get; set; }
public int DiscontinuedDisount { get; set; }
}

public class Supply : ????
{
// Primitives
public String UnitMeasurement { get; set; }
}

public class Part : ????
{
// Primitives
public String UnitMeasurement { get; set; }
}

public class Vehicle : ????
{
// Constructor
public Vehicle()
{
ExteriorFeatures = new HashSet<ProductFeature>();
InteriorFeatures = new HashSet<ProductFeature>();
SafetyFeatures = new HashSet<ProductFeature>();
}

// Primitives
public string VIN { get; set; }
public int Year { get; set; }
public int CylinderSize { get; set; }
public double EngineSize { get; set; }
public string StyleType { get; set; } //Truck, SUV, Sedan, Convertible, etc
public string TransmissionType { get; set; }
public string InteriorColor { get; set; }
public string ExteriorColor { get; set; }

// Foreign Keys
public virtual int MakeId { get; set; }


// Navigation Properties
// Classes
[ForeignKey("MakeId")]
public virtual VehicleMake Make { get; set; }

// Collections
public virtual ICollection<ProductFeature> InteriorFeatures { get; set; }
public virtual ICollection<ProductFeature> ExteriorFeatures { get; set; }
public virtual ICollection<ProductFeature> SafetyFeatures { get; set; }
}

设置继承的最佳方式是车辆、零件、用品和任何 future 的销售项目类 [例如。 clothing] 可以通过编码冗余属性而不必大惊小怪地添加?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com