【问题标题】:How to post some collection of <T> data to MVC action?如何将一些 <T> 数据集合发布到 MVC 操作?
【发布时间】:2015-12-09 00:28:17
【问题描述】:
public class Graphic
{
    ...
    ...
    [ScaffoldColumn(false)]
    public int GraphicId { get; set; }
    public virtual ICollection<GraphicArtwork> GraphicArtworks { get; set; }
}

public class GraphicArtwork
{
    [Key]
    public int GraphicArtworkId { get; set; }
    public int GraphisId { get; set; }
    [Required(ErrorMessage = "The {0} is required.")]
    [StringLength(500)]
    public string ArtOptionText { get; set; }
    public decimal Price { get; set; }
    [DisplayName("Active")]
    public bool IsActive { get; set; }
    public DateTime CreatedDate { get; set; }
    [NotMapped]
    public int TotalRecordCount { get; set; }
}

我有这两个表和模型。在这里,我有一个带有许多艺术作品的图形选项。我已经使用 Knockout.js 在视图中创建了我的艺术品选项。现在我的问题是如何发布(操作方法)这些数据以便我可以插入到 GraphicArtwork 表中。

【问题讨论】:

    标签: entity-framework asp.net-mvc-4 knockout.js


    【解决方案1】:
    [HttpPost]
    public ActionResult Add(Graphic data)
    {
      // "data" will contain all posted values  
    }
    

    【讨论】:

    • 我想要客户端逻辑以便我可以得到这个值
    猜你喜欢
    • 1970-01-01
    • 2013-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-15
    • 2016-09-12
    • 2018-10-02
    相关资源
    最近更新 更多