我想在一个视图中使用多个模型,并在视图中添加多个表中的记录 我的数据库如下图所示: (我使用vs2012 mvc4和EF)
我为每个表创建了四个模型,为所有
的存储库创建了“PreOrder”类 public class Orders
{
public long OrdersId { get; set; }
public string CustomerId { get; set; }
public long OrderListId { get; set; }
public int? CountProduct { get; set; }
public string CountPrice { get; set; }
public string VisitorsName { get; set; }
public DateTime? OrderDate { get; set; }
}
public class Product
{
public string ProductID { get; set; }
public string NameProduct { get; set; }
public string Price { get; set; }
}
public class Customers
{
public string CustomerID { get; set; }
[DisplayFormat(NullDisplayText = "-")]
public string Name { get; set; }
[DisplayFormat(NullDisplayText = "-")]
...
}
public class OrderList
{
public long OrderListID { get; set; }
public Nullable<long> OrdersId { get; set; }
public string ProductId { get; set; }
public Nullable<int> Count { get; set; }
public Nullable<decimal> DisCount { get; set; }
}
public class PreOrder
{
public Customers _Customer { set; get; }
public Product _Product { set; get; }
public Orders _Order { set; get; }
public OrderList _OrderList { set; get; }
}
我希望使用来自tblcustomers的名称,系列,customerid 和productId,NameProduct,价格从tblProducts 以及tblOrders和tblOrderList的所有字段 如何创建一个视图来填充表Orders和OrderList ??
答案 0 :(得分:1)