如何为ComplexType指定数组元素

时间:2013-04-25 09:22:10

标签: entity-framework

所以我有以下ComplexType:

[ComplexType]
public class TransactionSettings
{
    [Display(Name = "Minimum Order Amount"), Column(TypeName = "MONEY")]
    public decimal MinimumOrder { get; set; }
    [Display(Name = "Payment Provider")]
    public PaymentProvider PaymentProvider { get; set; }
    [Display(Name = "Provider Settings")]
    public ProviderSettings ProviderSettings { get; set; }
    [Display(Name = "Accepted Credit Cards")]
    public CreditCards[] AcceptedCreditCards { get; set; }
    [Display(Name = "Taxable States")]
    public States[] SalesTaxStates { get; set; }
}

public enum CreditCards
{
    MasterCard,
    Visa,
    [Description("American Express")]
    AmericanExpress,
    Discover
}

public enum States
{
    [Description("Alabama")]
    AL,
    [Description("Alaska")]
    AK,
    [Description("Arizona")]
    AZ,
    //.
    //.
    //.
    [Description("Wisconsin")]
    WI,
    [Description("Wyoming")]
    WY
}

数组表示特定字段将有多种选择。但是如您所知,复杂类型只能包含原始属性。那我怎么能做到这一点呢?

1 个答案:

答案 0 :(得分:0)

我通过将所有枚举标记为Flags来解决此问题。从那里开始很容易......