是否有使用视图模型插入相关表的正确方法

时间:2019-01-28 21:23:27

标签: c# asp.net-mvc-3 entity-framework-core

我如何使用viewModel插入一些联接表 使用实体框架核心

我已经尝试用相关表的字段创建一个viewModel

namespace PrimeDelivery.ViewModels
{
    public class CreateOrder
    {
        public TblIOrderHeader Orderheader { get; set; }
        public TblorderItems orderItems { get; set; }
        public TblTrackingNumbers trackingNumbers { get; set; }
        public virtual ICollection<TblItems> Items { get; set; }
    }
}

和OrderHeaders表

public partial class TblOrderHeader
{
    public TblOrderHeader()
    {
        TblCheckedIn = new HashSet<TblCheckedIn>();
        TblDocumants = new HashSet<TblDocumants>();
        TblImages = new HashSet<TblImages>();
        TblOrdersDates = new HashSet<TblIodates>();
        TblOrderItems = new HashSet<TblIorderItems>();
        TblTrackingNumbers = new HashSet<TblTrackingNumbers>();
    }

    public int orderId { get; set; }
    public int ClientId { get; set; }
    public string NameOnShipment { get; set; }
    public string Notes { get; set; }
    public bool ReceivingPhotoRequest { get; set; }
    public bool RequestPaperWork { get; set; }
    public int StatusId { get; set; }
    public int CreateBy { get; set; }

    public virtual TblStatus Status { get; set; }
    public virtual ICollection<TblCheckedIn> TblCheckedIn { get; set; }
    public virtual ICollection<TblDocumants> TblDocumants { get; set; }
    public virtual ICollection<TblImages> TblImages { get; set; }
    public virtual ICollection<TblIodates> TblIodates { get; set; }
    public virtual ICollection<TblIorderItems> TblIorderItems { get; set; }
    public virtual ICollection<TblTrackingNumbers> TblTrackingNumbers { 
   get; set; }
      }
 }

要插入到所有相关表中

0 个答案:

没有答案