How to use interface properties with CodeFirst

后端 未结 7 2066
自闭症患者
自闭症患者 2020-12-01 01:17

I have the following entities:

public interface IMyEntity
{
    [Key]
    int Id { get; set; }
    IMyDetail MyDetail { get; set; }
    ICollection

        
7条回答
  •  情深已故
    2020-12-01 02:12

    I had a simliar case and I solved it this way:

    public class Order : IOrder
    {
         public string FirstName { get; set; }
         public string LastName { get; set; }
         public List Items {get; set;} = new List(); 
         IEnumerable IOrder.Items
            {
                get { return Items; }
                set { Items = value as List; }
            }
    }
    
    public class OrderItem: IOrderItem
    {
        public string Name {get; set;}
        public decimal Price {get; set;}
    }
    

提交回复
热议问题