2011-11-16 118 views
0

CS。多表,抽象類,實體類型

public abstract class Customer 
    { 
     public int Id { get; set; } 
     public string Name { get; set; } 
     public bool IsCorporate { get; set; } 
    } 

    public class PrivateCustomer: Customer 
    { 
     public string Address { get; set; } 
     public DateTime DateOfContract { get; set; } 
     public int QuoteAmmount { get; set; } 
     public string PromotionCode { get; set; } 
    } 

    public class BusinesCustomer: Customer 
    { 
     public string BusinessName { get; set; } 
     public string BusinessAddress { get; set; } 
     public TypeofContract ContractType { get; set; } 
     public DateTime ContractStart { get; set; } 
     public DateTime ContractEnd { get; set; } 
    } 

    public enum TypeofContract 
    { 
     Hourly =1, 
     Daily = 2, 
     Weekly = 3 

    } 

DB寄存= DB Entity Design Existing

看到了一些例子:http://i.msdn.microsoft.com/dynimg/IC315206.gif,他們已經完成了課程 - > OnlineCourse和OnsiteCourse不可能找到它的C#層。

任何人有任何想法我如何解決EF代碼的第一種方法。

親切的問候 Vinay。

回答

1

下面通過聲明表頭來解決問題。

public abstract class Customer 
{ 
    public int Id { get; set; } 
    public string Name { get; set; } 
    public bool IsCorporate { get; set; } 
} 

[Table("PrivateCustomer")] 
public class PrivateCustomer: Customer 
{ 
    public string Address { get; set; } 
    public DateTime DateOfContract { get; set; } 
    public int QuoteAmmount { get; set; } 
    public string PromotionCode { get; set; } 
} 

[Table("BusinesCustomer")] 
public class BusinesCustomer: Customer 
{ 
    public string BusinessName { get; set; } 
    public string BusinessAddress { get; set; } 
    public TypeofContract ContractType { get; set; } 
    public DateTime ContractStart { get; set; } 
    public DateTime ContractEnd { get; set; } 
} 

public enum TypeofContract 
{ 
    Hourly =1, 
    Daily = 2, 
    Weekly = 3 

}