如何在Asp.NET MVC中从视图到控制器发布一对多关系数据

时间:2017-08-24 06:32:46

标签: c# asp.net asp.net-mvc asp.net-mvc-4

那里,我想将购买记录发布到控制器,我的模型包含以下两个类,名为Purchase和PurchaseDetails

    public partial class Purchase
{
    public Purchase()
    {
        this.PurchaseDetails = new HashSet<PurchaseDetail>();
    }

    public int purchaseId { get; set; }
    public System.DateTime purchaseDate { get; set; }
    public int vendorCode { get; set; }
    public string vendorName { get; set; }
    public int purVoucherNo { get; set; }

    public virtual ICollection<PurchaseDetail> PurchaseDetails { get; set; }
}

public partial class PurchaseDetail
{
    public int code { get; set; }
    public int purchaseDetailsId { get; set; }
    public string serialNo { get; set; }
    public int productCode { get; set; }
    public string productName { get; set; }
    public string unitOfMeasure { get; set; }
    public int quantity { get; set; }
    public decimal purchasePrice { get; set; }
    public decimal amount { get; set; }

    public virtual Purchase Purchase { get; set; }
}

现在,首先,我想在表格中动态存储和显示购买详细信息数据  其次,我想将Purchase的一个对象和PurchaseDetails的多个对象传递给Controller 。请帮我。我不知道如何完成这项任务。

0 个答案:

没有答案