在EF4 CTP4 Code First中具有附加有效载荷列的连接表

时间:2010-12-02 18:54:31

标签: ctp4 ef-code-first

我有以下表格:

WOPartList(定义具有1个或更多Part_Size的部分) WOPartSize(定义具有1个或多个Part_Size的大小)

Part_Size(联接表作为addt有效负载列,如sku,on_hand等...)

以下是DAL的POCO课程:

    // Real World Scenario:

    // PartList                Related to Part_Size     Related to PartSize  
    //
    // #8 Stainless Lag Bolt   sku- 87234018            size- 2 x 1/2  
    //                         on hand- 214 
    //                         on order- 12 

    // #8 Stainless Lag Bolt   sku- 87234199            size- 3 x 1/2  
    //                         on hand- 81 
    //                         on order- 18 


    // #10 Stainless Lag Bolt  sku- 87237835            size- 1 x 1/2  
    //                         on hand- 11 
    //                         on order- 14 

    // #10 Stainless Lag Bolt  sku- 87237835            size- 2 x 1/2  
    //                         on hand- 11 
    //                         on order- 14 

    // #10 Stainless Lag Bolt  sku- 87237835            size- 3 x 1/2  
    //                         on hand- 11 
    //                         on order- 14 

    // So the idea is to be able to create a size once and use it many times
    // for many different parts... But I need to keep specific statistics for
    // each size of a part...

    // How do I tell the Model that Part_Size is a many-to-many junction table
    // between WOPartSize and WOPartsList as well ?


public class WOPartSize
{

    public int WOPartSizeId { get; set; }
    public DateTime tadded { get; set; }
    public string size { get; set; }

    // Nav Collections
    public virtual ICollection<Part_Size> Parts { get; set; }

}


public class Part_Size   // Junction Table
{
    public int WOPartSizeMMId { get; set; }

    public string part_no { get; set; }
    public string part_descr { get; set; }
    public string sku { get; set; }
    public decimal cost_each { get; set; }
    public decimal price_each { get; set; }
    public int on_hand { get; set; }
    public int on_trucks { get; set; }
    public int on_order { get; set; }

    // Put ICollections<> here ?

}

public class WOPartsList
{

    public int WOPartsListId { get; set; }
    public DateTime tadded { get; set; }
    public string part_descr { get; set; }

    // Nav References
    public virtual WOPartType PartType { get; set; }
    public int WOPartTypeId { get; set; }

    public virtual ICollection<Part_Size> Sizes { get; set; }

}

如何配置联结表?注释?流畅的API?我的主要麻烦是在联结表中获取额外的有效负载字段...否则我只是让EF为我生成表并且没有POCO类......

0 个答案:

没有答案
相关问题