我有以下Customer
课程:
public class Customer : EntityBase<Customer>
{
public virtual int ID { get; set; }
public virtual CustomerType CustomerType { get; set; }
public virtual string CompanyName { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual ICollection<Address> BillingAddresses { get; set; }
public virtual ICollection<Address> ShippingAddresses { get; set; }
}
该类Address
如下所示:
public class Address : EntityBase<Address>
{
public virtual int ID { get; set; }
public virtual AddressType AddressType { get; set; }
public virtual bool IsDefault { get; set; }
public virtual string Name { get; set; }
public virtual string Line1 { get; set; }
public virtual string Line2 { get; set; }
public virtual string Line3 { get; set; }
public virtual string City { get; set; }
public virtual string State { get; set; }
public virtual string ZipCode { get; set; }
public virtual string Country { get; set; }
public virtual int CustomerID { get; set; }
public virtual Customer Customer { get; set; }
}
我希望能够在客户类中拥有多个每种类型的地址,但我很难弄清楚这一点。
我想以这样的方式结束,以获取每种类型的默认地址。
public Address DefaultBillingAddress
{
get
{
return BillingAddresses.First(x => x.IsDefault == true);
}
}
我遇到的问题是如何区分AddressType
每个枚举之间的区别ICollection
?